-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem details in modules #3557
problem details in modules #3557
Conversation
I have fixed feelings. I like it but then is like we need to add the a new property in Jooby class isn't wrong but wonder if we could do it using an Extension + install call
Once installed take care of configure everything. The issue here is how to integrate with other error handler like validation |
Just for clarity, there is no new property in Regarding module install(new ProblemsDetailsModule()); If a new module only sets the same hocon config as it is now(just code-driven approach) it will work. But this module should always be registered before validation modules. If the module should also register the handler |
@kliushnichenko thanks for explaining let's proceed with documentation. |
docs and some minor improvements added. |
@@ -192,4 +201,25 @@ private void logProblem(Context ctx, HttpProblem problem, Throwable cause) { | |||
private String buildLogMsg(Context ctx, HttpProblem problem, StatusCode statusCode) { | |||
return "%s | %s".formatted(ErrorHandler.errorMessage(ctx, statusCode), problem.toString()); | |||
} | |||
|
|||
public static ProblemDetailsHandler fromConfig(Config config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to from
and let's add javadoc
* @author kliushnichenko | ||
* @since 3.4.2 | ||
*/ | ||
public class JsonPointer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just few minor changes
While was working on problem details support in validation modules the general concept a bit changed.
Enabling the
ProblemDetailsHandler
moved to thehocon
configuration.It greatly simplifies the integration of problem details in modules. Modules can now detect if
ProblemDetailsHandler
is enabled at an early stage of the module initiation. With the previous approach, it would have been much harder and might have led to implementing awkward solutions.An additional benefit of the new approach is that
ProblemDetailsHandler
will be automatically registered as the last handler in the error handlers chain, so dev no longer need to worry about that.So, to enable
ProblemDetailsHandler
the next config now required:@jknack pls share your thoughts, if you are Ok with the new approach I'll continue with docs update and some minor improvements