-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#282: get error extension `code` from exception name or annotation
- Loading branch information
Showing
15 changed files
with
208 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
server/api/src/main/java/io/smallrye/graphql/api/ErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.smallrye.graphql.api; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RUNTIME) | ||
@Target({ TYPE, ANNOTATION_TYPE }) | ||
public @interface ErrorCode { | ||
String value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/tck/src/test/java/io/smallrye/graphql/test/apps/error/api/ErrorApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.smallrye.graphql.test.apps.error.api; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
import io.smallrye.graphql.api.ErrorCode; | ||
|
||
@GraphQLApi | ||
public class ErrorApi { | ||
@Query | ||
public String unsupportedOperation() { | ||
throw new UnsupportedOperationException("dummy-message"); | ||
} | ||
|
||
public static class CustomBusinessException extends RuntimeException { | ||
} | ||
|
||
@Query | ||
public String customBusinessException() { | ||
throw new CustomBusinessException(); | ||
} | ||
|
||
@ErrorCode("some-business-error-code") | ||
public static class AnnotatedCustomBusinessException extends RuntimeException { | ||
} | ||
|
||
@Query | ||
public String annotatedCustomBusinessException() { | ||
throw new AnnotatedCustomBusinessException(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
server/tck/src/test/resources/tests/errors/annotatedCustomException/input.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
annotatedCustomBusinessException | ||
} |
24 changes: 24 additions & 0 deletions
24
server/tck/src/test/resources/tests/errors/annotatedCustomException/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"message": "Unexpected failure in the system. Jarvis is working to fix it.", | ||
"locations": [ | ||
{ | ||
"line": 2, | ||
"column": 3 | ||
} | ||
], | ||
"path": [ | ||
"annotatedCustomBusinessException" | ||
], | ||
"extensions": { | ||
"exception": "io.smallrye.graphql.test.apps.error.api.ErrorApi$AnnotatedCustomBusinessException", | ||
"classification": "DataFetchingException", | ||
"code": "some-business-error-code" | ||
} | ||
} | ||
], | ||
"data": { | ||
"annotatedCustomBusinessException": null | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
server/tck/src/test/resources/tests/errors/annotatedCustomException/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## error extension `code` derived from the `@GraphQlErrorCode` annotation on a custom exception | ||
|
||
ignore=false | ||
priority=100 |
3 changes: 3 additions & 0 deletions
3
server/tck/src/test/resources/tests/errors/builtInException/input.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
unsupportedOperation | ||
} |
24 changes: 24 additions & 0 deletions
24
server/tck/src/test/resources/tests/errors/builtInException/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"message": "Unexpected failure in the system. Jarvis is working to fix it.", | ||
"locations": [ | ||
{ | ||
"line": 2, | ||
"column": 3 | ||
} | ||
], | ||
"path": [ | ||
"unsupportedOperation" | ||
], | ||
"extensions": { | ||
"exception": "java.lang.UnsupportedOperationException", | ||
"classification": "DataFetchingException", | ||
"code": "unsupported-operation" | ||
} | ||
} | ||
], | ||
"data": { | ||
"unsupportedOperation": null | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
server/tck/src/test/resources/tests/errors/builtInException/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## error extension `code` derived from the class name of a jdk exception | ||
|
||
ignore=false | ||
priority=100 |
3 changes: 3 additions & 0 deletions
3
server/tck/src/test/resources/tests/errors/customException/input.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
customBusinessException | ||
} |
24 changes: 24 additions & 0 deletions
24
server/tck/src/test/resources/tests/errors/customException/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"message": "Unexpected failure in the system. Jarvis is working to fix it.", | ||
"locations": [ | ||
{ | ||
"line": 2, | ||
"column": 3 | ||
} | ||
], | ||
"path": [ | ||
"customBusinessException" | ||
], | ||
"extensions": { | ||
"exception": "io.smallrye.graphql.test.apps.error.api.ErrorApi$CustomBusinessException", | ||
"classification": "DataFetchingException", | ||
"code": "custom-business" | ||
} | ||
} | ||
], | ||
"data": { | ||
"customBusinessException": null | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
server/tck/src/test/resources/tests/errors/customException/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## error extension `code` derived from the class name of a custom exception | ||
|
||
ignore=false | ||
priority=100 |