Skip to content

Commit dfe86bc

Browse files
smyrickdariuszkuc
authored andcommitted
feat: move and label all exceptions (#101)
* feat: wrap all exceptions * feat: move and label all exceptions * test: add more unit tests for exceptions
1 parent 9379dc6 commit dfe86bc

32 files changed

+206
-62
lines changed

example/src/main/kotlin/com.expedia.graphql.sample/directives/CakeOnlyDirectiveWiring.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class CakeOnlyDirectiveWiring : DirectiveWiring {
99
override fun isApplicable(environment: SchemaDirectiveWiringEnvironment<*>): Boolean =
1010
environment.directive.name == getDirectiveName(CakeOnly::class)
1111

12+
@Throws(RuntimeException::class)
1213
override fun onField(wiringEnv: SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition>): GraphQLFieldDefinition {
1314
val field = wiringEnv.element
1415
val originalDataFetcher: DataFetcher<Any> = field.dataFetcher
@@ -21,4 +22,4 @@ class CakeOnlyDirectiveWiring : DirectiveWiring {
2122
}
2223
return field.transform { it.dataFetcher(cakeOnlyFetcher) }
2324
}
24-
}
25+
}

example/src/main/kotlin/com.expedia.graphql.sample/query/NestedQueries.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AnimalDetailsDataFetcher : DataFetcher<NestedAnimalDetails>, BeanFactoryAw
3939
this.beanFactory = beanFactory
4040
}
4141

42+
@Throws(Exception::class)
4243
override fun get(environment: DataFetchingEnvironment?): NestedAnimalDetails {
4344
val id = environment?.getSource<NestedAnimal>()?.id
4445
if (id == null) {

example/src/main/kotlin/com.expedia.graphql.sample/validation/DataFetcherExecutionValidator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class DataFetcherExecutionValidator(private val validator: Validator) : DataFetc
2020
}
2121
}
2222

23+
@Throws(ValidationException::class)
2324
override fun onFailure(evaluationResult: Any, parameter: Parameter, argumentName: String, environment: DataFetchingEnvironment): Nothing {
2425
val violations = evaluationResult as Set<ConstraintViolation<*>>
2526
throw ValidationException(violations.map { it.asConstraintError() })

src/main/kotlin/com/expedia/graphql/schema/exceptions/ConflictingTypesException.kt renamed to src/main/kotlin/com/expedia/graphql/exceptions/ConflictingTypesException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.expedia.graphql.schema.exceptions
1+
package com.expedia.graphql.exceptions
22

33
import kotlin.reflect.KClass
44

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.expedia.graphql.exceptions
2+
3+
import kotlin.reflect.KType
4+
5+
/**
6+
* Thrown if could not cast the KType.classifier to KClass
7+
*/
8+
class CouldNotCastToKClassException(kType: KType)
9+
: GraphQLKotlinException("Could not cast the KType.classifier to KClass. KType=$kType")

src/main/kotlin/com/expedia/graphql/schema/exceptions/CouldNotGetJvmNameOfKTypeException.kt renamed to src/main/kotlin/com/expedia/graphql/exceptions/CouldNotGetJvmNameOfKTypeException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.expedia.graphql.schema.exceptions
1+
package com.expedia.graphql.exceptions
22

33
import kotlin.reflect.KType
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.expedia.graphql.schema.exceptions
1+
package com.expedia.graphql.exceptions
22

33
import kotlin.reflect.KClass
44

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.expedia.graphql.exceptions
2+
3+
import kotlin.reflect.KParameter
4+
5+
/**
6+
* Thrown when unable to get the simple name of a function argument
7+
*/
8+
class CouldNotGetNameOfArgumentException(kParameter: KParameter)
9+
: GraphQLKotlinException("Could not get name of parameter $kParameter")

src/main/kotlin/com/expedia/graphql/schema/exceptions/CouldNotGetNameOfEnumException.kt renamed to src/main/kotlin/com/expedia/graphql/exceptions/CouldNotGetNameOfEnumException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.expedia.graphql.schema.exceptions
1+
package com.expedia.graphql.exceptions
22

33
import kotlin.reflect.KClass
44

src/main/kotlin/com/expedia/graphql/schema/exceptions/GraphQLKotlinException.kt renamed to src/main/kotlin/com/expedia/graphql/exceptions/GraphQLKotlinException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.expedia.graphql.schema.exceptions
1+
package com.expedia.graphql.exceptions
22

33
/**
44
* Base exception that all our library exceptions extend from.

0 commit comments

Comments
 (0)