some ideas about exception handling
See original GitHub issueHi @berndruecker, I have an idea about the exception handling strategy - DefaultCommandExceptionHandlingStrategy
. We provide a default exception handling policy. If the user provides a custom exception handling policy, the custom policy will be activated.
- interface
public interface CommandExceptionHandlingStrategy {
void handleCommandError(JobClient jobClient, ActivatedJob job, Throwable throwable);
}
- default handling strategy
public class DefaultCommandExceptionHandlingStrategy implements CommandExceptionHandlingStrategy {
@Override
public void handleCommandError(JobClient jobClient, ActivatedJob job, Throwable throwable) {
//TODO
}
}
- Inject DefaultCommandExceptionHandlingStrategy when missing bean
@Bean
@ConditionalOnMissingBean(CommandExceptionHandlingStrategy.class)
public CommandExceptionHandlingStrategy commandExceptionHandlingStrategy() {
return new DefaultCommandExceptionHandlingStrategy();
}
If the user provides a custom exception handling policy, the custom policy will be activated
public class CustomCommandExceptionHandlingStrategy implements CommandExceptionHandlingStrategy {
@Override
public void handleCommandError(JobClient jobClient, ActivatedJob job, Throwable throwable) {
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
What is Exception Handling? - SearchSoftwareQuality
Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events...
Read more >9 Best Practices to Handle Java Exceptions - Stackify
Handling Java exceptions isn't easy, especially for beginners. Read this post to understand exceptions and best practices for using them.
Read more >Clean Code and the Art of Exception Handling - Toptal
Exception Handling : It's a Good Thing · Always create your own ApplicationError hierarchy · Never rescue Exception · Never rescue more exceptions...
Read more >Exception handling - Wikipedia
In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions ...
Read more >Topic: Exception Handling
Exceptional conditions are any unexpected occurrences that are not accounted for in a system's normal operation. It is difficult to protect a system...
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
I looked into this again - as I need conditional beans for some other thing again. I think I found a really easy way to achieve this also with pure spring:
@lzgabel WDYT?
Thanks for the proposal - I am not sure if I come to work on this this year, but will take it into consideration 👍