Skip to content

Commit a1334cd

Browse files
Merge pull request #935 from parsharma/519
mp.graphql.showErrorMessage - wildcard
2 parents dadfe7f + e318b84 commit a1334cd

10 files changed

Lines changed: 98 additions & 4 deletions

File tree

server/implementation/src/main/java/io/smallrye/graphql/spi/config/Config.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,16 @@ default boolean isListed(Class throwableClass, List<String> classNames) {
8686
}
8787

8888
// Check that specific class
89-
if (classNames.contains(throwableClass.getName())) {
90-
return true;
89+
for (String configuredValue : classNames) {
90+
if (configuredValue.equals(throwableClass.getName())) {
91+
return true;
92+
} else if (configuredValue.endsWith("*")) {
93+
String values = configuredValue.substring(0, configuredValue.length() - 2);
94+
if (throwableClass.getName().startsWith(values)) {
95+
return true;
96+
}
97+
continue;
98+
}
9199
}
92100

93101
// Check transitive

server/tck/src/test/java/io/smallrye/graphql/SmallRyeGraphQLArchiveProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.smallrye.graphql.test.apps.defaultvalue.api.DefaultValueParrotAPI;
1919
import io.smallrye.graphql.test.apps.enumlist.api.EnumListApi;
2020
import io.smallrye.graphql.test.apps.error.api.ErrorApi;
21+
import io.smallrye.graphql.test.apps.exceptionlist.ExceptionListApi;
2122
import io.smallrye.graphql.test.apps.fieldexistence.api.FieldExistenceApi;
2223
import io.smallrye.graphql.test.apps.generics.api.ControllerWithGenerics;
2324
import io.smallrye.graphql.test.apps.grouping.api.BookGraphQLApi;
@@ -97,6 +98,8 @@ public void process(Archive<?> applicationArchive, TestClass testClass) {
9798
war.addPackage(FieldExistenceApi.class.getPackage());
9899
war.addPackage(CreatorApi.class.getPackage());
99100
war.addPackage(EnumListApi.class.getPackage());
101+
war.addPackage(ExceptionListApi.class.getPackage());
102+
100103
}
101104
}
102105
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.smallrye.graphql.test.apps.exceptionlist;
2+
3+
import org.eclipse.microprofile.graphql.GraphQLApi;
4+
import org.eclipse.microprofile.graphql.Query;
5+
6+
@GraphQLApi
7+
public class ExceptionListApi {
8+
9+
@Query
10+
public String checkedException() throws MyCheckedException {
11+
throw new MyCheckedException("This error should not show");
12+
}
13+
14+
@Query
15+
public String uncheckedException() throws MyUncheckedException {
16+
throw new MyUncheckedException("This error should show");
17+
}
18+
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.smallrye.graphql.test.apps.exceptionlist;
2+
3+
public class MyCheckedException extends Exception {
4+
5+
public MyCheckedException(String errMsg) {
6+
super(errMsg);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.smallrye.graphql.test.apps.exceptionlist;
2+
3+
public class MyUncheckedException extends RuntimeException {
4+
5+
public MyUncheckedException(String errMsg) {
6+
super(errMsg);
7+
}
8+
}

server/tck/src/test/resources/META-INF/microprofile-config.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ smallrye.graphql.printDataFetcherException=true
22
smallrye.graphql.tracing.enabled=true
33
smallrye.graphql.allowGet=true
44
smallrye.graphql.logPayload=true
5-
mp.graphql.showErrorMessage=java.security.AccessControlException
6-
mp.graphql.hideErrorMessage=java.io.IOException
5+
6+
mp.graphql.showErrorMessage=java.security.AccessControlException,io.smallrye.graphql.test.apps.exceptionlist.*
7+
mp.graphql.hideErrorMessage=java.io.IOException,io.smallrye.graphql.test.apps.exceptionlist.*
78
smallrye.graphql.errorExtensionFields=exception,classification,code,description,validationErrorType,queryPath
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
checkedException
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"errors": [
3+
{
4+
"message": "Unexpected failure in the system. Jarvis is working to fix it.",
5+
"locations": [
6+
{
7+
"line": 2,
8+
"column": 5
9+
}
10+
],
11+
"path": [
12+
"checkedException"
13+
]
14+
}
15+
],
16+
"data": {
17+
"checkedException": null
18+
}
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
uncheckedException
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"errors": [
3+
{
4+
"message": "This error should show",
5+
"locations": [
6+
{
7+
"line": 2,
8+
"column": 5
9+
}
10+
],
11+
"path": [
12+
"uncheckedException"
13+
],
14+
"extensions": {
15+
"classification": "DataFetchingException"
16+
}
17+
}
18+
],
19+
"data": {
20+
"uncheckedException": null
21+
}
22+
}

0 commit comments

Comments
 (0)