Skip to content

Commit b980c28

Browse files
smyrickamandaducrou
authored andcommitted
feat: base exception (#49)
Creating a base exception for the entire library makes stack traces more clear and easier for clients to catch any exception while still being specific
1 parent 40be73a commit b980c28

10 files changed

+16
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import kotlin.reflect.KClass
88
* in the GraphQLType so all names must be unique.
99
*/
1010
class ConflictingTypesException(kClass1: KClass<*>, kClass2: KClass<*>)
11-
: RuntimeException("Conflicting class names in schema generation [$kClass1, $kClass2]")
11+
: GraphQLKotlinException("Conflicting class names in schema generation [$kClass1, $kClass2]")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import kotlin.reflect.KType
66
* Thrown when trying to generate a class and cannot resolve the jvm erasure name.
77
*/
88
class CouldNotGetJvmNameOfKTypeException(kType: KType?)
9-
: RuntimeException("Could not get the name of the KClass $kType")
9+
: GraphQLKotlinException("Could not get the name of the KClass $kType")

src/main/kotlin/com/expedia/graphql/schema/exceptions/CouldNotGetNameOfAnnotationException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import kotlin.reflect.KClass
66
* Thrown when unable to get the annotaiton name of a KAnnotatedElement.
77
*/
88
class CouldNotGetNameOfAnnotationException(kClass: KClass<*>)
9-
: RuntimeException("Could not get name of annotation class $kClass")
9+
: GraphQLKotlinException("Could not get name of annotation class $kClass")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import kotlin.reflect.KClass
66
* Thrown when trying to generate an enum class and cannot resolve the simple name.
77
*/
88
class CouldNotGetNameOfEnumException(kclass: KClass<*>)
9-
: RuntimeException("Could not get the enum name of the KClass $kclass")
9+
: GraphQLKotlinException("Could not get the enum name of the KClass $kclass")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.expedia.graphql.schema.exceptions
2+
3+
/**
4+
* Base exception that all our library exceptions extend from.
5+
*/
6+
open class GraphQLKotlinException(message: String = "", throwable: Throwable? = null)
7+
: RuntimeException(message, throwable)

src/main/kotlin/com/expedia/graphql/schema/exceptions/InvalidInputFieldTypeException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ package com.expedia.graphql.schema.exceptions
2828
*
2929
* data class PartOfUnion( val property: Int) : UnionMarkup
3030
*/
31-
class InvalidInputFieldTypeException : RuntimeException("Object field argument cannot be an interface or a union")
31+
class InvalidInputFieldTypeException : GraphQLKotlinException("Object field argument cannot be an interface or a union")

src/main/kotlin/com/expedia/graphql/schema/exceptions/InvalidListTypeException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import kotlin.reflect.KType
66
* Thrown on mapping an invalid list type
77
*/
88
class InvalidListTypeException(type: KType)
9-
: RuntimeException("Could not get the type of the first argument for the list $type")
9+
: GraphQLKotlinException("Could not get the type of the first argument for the list $type")

src/main/kotlin/com/expedia/graphql/schema/exceptions/InvalidSchemaException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package com.expedia.graphql.schema.exceptions
33
/**
44
* Exception thrown on schema creation if no queries and no mutations are specified.
55
*/
6-
class InvalidSchemaException : RuntimeException("Schema requires at least one query or mutation")
6+
class InvalidSchemaException : GraphQLKotlinException("Schema requires at least one query or mutation")

src/main/kotlin/com/expedia/graphql/schema/exceptions/NestingNonNullTypeException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import kotlin.reflect.KType
77
* Throws on nesting a non-null graphql type twice.
88
*/
99
class NestingNonNullTypeException(gType: GraphQLType, kType: KType)
10-
: RuntimeException("Already non null, don't need to nest, $gType, $kType")
10+
: GraphQLKotlinException("Already non null, don't need to nest, $gType, $kType")

src/main/kotlin/com/expedia/graphql/schema/exceptions/TypeNotSupportedException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ package com.expedia.graphql.schema.exceptions
44
* Thrown when the generator does not have a type to map to in GraphQL or in the hooks.
55
*/
66
class TypeNotSupportedException(typeName: String, packageList: List<String>)
7-
: RuntimeException("Cannot convert $typeName since it is outside the supported packages $packageList")
7+
: GraphQLKotlinException("Cannot convert $typeName since it is outside the supported packages $packageList")

0 commit comments

Comments
 (0)