Custom data for all problem exceptions
See original GitHub issueHi!
I want to add different values to all exceptions. For example zipkin traceId.
I have added:
@Configuration
class SpringDataRestConfiguration extends RepositoryRestConfigurerAdapter {
@Override
public void configureJacksonObjectMapper(ObjectMapper objectMapper) {
objectMapper
.registerModule(new ProblemModule())
.registerModule(new ConstraintViolationProblemModule());
}
}
but when I try to override methods in:
@ControllerAdvice
class GlobalExceptionHandler implements ProblemHandling {
}
I end up with getting the full problem serialized cause, stackTrace, etc.
I must have misunderstood anything about the customization. But do you have any good way to add custom data and how to do the customization?
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (3 by maintainers)
Top Results From Across the Web
Add Custom Data to Exceptions -- Visual Studio Magazine
You can add additional information to any Exception object to help you debug your application when something goes horribly wrong.
Read more >Implement Custom Exceptions in Java: Why, When and How
Learn 4 best practices for custom exceptions in Java. Understand when and how to use them in your application.
Read more >Should we use custom exceptions in Python? | by Marcin Kozak
recommends using custom exceptions when one creates an interface or a library, as this helps diagnose problems that have occurred in the code....
Read more >Custom errors, extending Error - The Modern JavaScript Tutorial
Look at Wrapping exceptions example. All the exceptions-related code there does nothing good. It just bloats the code. The rule of thumb: Never ......
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Ensure that exception data is available when code executes remotely ... When you create user-defined exceptions, ensure that the metadata for the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe adding a
toProblemBuilder()
method in Problem would help (forcing implementations to implement it) ?Exactly. No, there is no good workaround to me knowledge at least. Custom JSON post-processor using Jackson + Spring, maybe. But it won’t be nice either.