-
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.
Merge pull request #910 from jmartisk/main-issue-903
Unify client errors for missing URL, suggest a different fix if runni…
- Loading branch information
Showing
8 changed files
with
96 additions
and
17 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
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
10 changes: 10 additions & 0 deletions
10
.../implementation/src/main/java/io/smallrye/graphql/client/DefaultErrorMessageProvider.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,10 @@ | ||
package io.smallrye.graphql.client; | ||
|
||
public class DefaultErrorMessageProvider implements ErrorMessageProvider { | ||
|
||
@Override | ||
public RuntimeException urlMissingErrorForNamedClient(String name) { | ||
return SmallRyeGraphQLClientMessages.msg.urlNotConfiguredForNamedClient(name); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
client/implementation/src/main/java/io/smallrye/graphql/client/ErrorMessageProvider.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,26 @@ | ||
package io.smallrye.graphql.client; | ||
|
||
import java.util.ServiceLoader; | ||
|
||
/** | ||
* Some error messages might differ depending on what appserver/runtime we are running inside. | ||
* SmallRye provides a default error message provider, but some runtimes may choose to override it. | ||
*/ | ||
public interface ErrorMessageProvider { | ||
|
||
RuntimeException urlMissingErrorForNamedClient(String name); | ||
|
||
static ErrorMessageProvider get() { | ||
ServiceLoader<ErrorMessageProvider> providers = ServiceLoader.load(ErrorMessageProvider.class); | ||
ErrorMessageProvider chosenProvider = null; | ||
for (ErrorMessageProvider provider : providers) { | ||
// pick the a provided non-default one, if it exists | ||
// otherwise use the default provider | ||
if (chosenProvider == null || !provider.getClass().equals(DefaultErrorMessageProvider.class)) { | ||
chosenProvider = provider; | ||
} | ||
} | ||
return chosenProvider; | ||
} | ||
|
||
} |
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
1 change: 1 addition & 0 deletions
1
...tion/src/main/resources/META-INF/services/io.smallrye.graphql.client.ErrorMessageProvider
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 @@ | ||
io.smallrye.graphql.client.DefaultErrorMessageProvider |