File tree Expand file tree Collapse file tree
jdk_8_maven/cs/graphql/graphql-ncs/src/main/kotlin/org/graphqlncs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org.graphqlncs
2+
3+ import graphql.ErrorClassification
4+ import graphql.ErrorType
5+
6+
7+ open class ExpTy (
8+ errorMessage : String? = " " ,
9+ private val parameters : Map <String , Any >? = mutableMapOf()
10+ ) : GraphQLException(errorMessage) {
11+ override val message: String?
12+ get() = super .message
13+
14+ override fun getExtensions (): MutableMap <String , Any > {
15+ return mutableMapOf (" parameters" to (parameters ? : mutableMapOf ()))
16+ }
17+
18+ override fun getErrorType (): ErrorClassification {
19+ return ErrorType .ValidationError
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package org .graphqlncs ;
2+
3+ import graphql .ErrorClassification ;
4+ import graphql .GraphQLError ;
5+ import graphql .language .SourceLocation ;
6+
7+ import java .util .List ;
8+
9+ public class GraphQLException extends RuntimeException implements GraphQLError {
10+
11+ String customMessage ;
12+
13+ public GraphQLException (String customMessage ) {
14+ this .customMessage = customMessage ;
15+ }
16+
17+ @ Override
18+ public String getMessage () {
19+ return customMessage ;
20+ }
21+
22+ @ Override
23+ public List <SourceLocation > getLocations () {
24+ return null ;
25+ }
26+
27+ @ Override
28+ public ErrorClassification getErrorType () {
29+ return null ;
30+ }
31+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package org.graphqlncs.resolver
22
33import graphql.kickstart.tools.GraphQLQueryResolver
44import org.graphqlncs.Exep
5+ import org.graphqlncs.ExpTy
56import org.graphqlncs.type.*
67import org.springframework.http.ResponseEntity
78import org.springframework.stereotype.Component
@@ -36,14 +37,14 @@ open class QueryResolver(
3637 fun remainder (a : Int , b : Int ): Int {
3738 val lim = 10000
3839 return if (a > lim || a < - lim || b > lim || b < - lim) {
39- throw Exep (" 400" )
40+ throw ExpTy (" 400" )
4041 } else remainder.exe(a, b)
4142 }
4243
4344 fun bessj (n : Int , x : Double ): Double {
4445
4546 return if (n <= 2 || n > 1000 ) {
46- throw Exep (" 400" )
47+ throw ExpTy (" 400" )
4748
4849 } else
4950 bessj.bessj(n, x)
You can’t perform that action at this time.
0 commit comments