Skip to content
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

[FEATURE] Default value return in case of exception #3742

Open
yelg opened this issue Sep 10, 2024 · 0 comments
Open

[FEATURE] Default value return in case of exception #3742

yelg opened this issue Sep 10, 2024 · 0 comments

Comments

@yelg
Copy link

yelg commented Sep 10, 2024

Describe the feature
Instead of :
public String calc(){
try {
return calcIntern();
} catch (Exception1 e1) {
return "val1";
} catch (Exception2 e1) {
return "val2";
}
}

we can simplify the code with this new feature as:

@DefaultInCaseOfException(value="val" )
@DefaultInCaseOfException(ex = Exception1, value="val1" )
@DefaultInCaseOfException(ex = Exception2, value="val2" )
public String calc(){
return calcIntern();
}

OR

@DefaultInCaseOfException(value="val" )
public String calc(){
return calcIntern();
}

Describe the target audience
Developper

Additional context
Can be seen as a kind of static circuit breaker
the value can be of any type (not only string)
value can be also a lambda

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant