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] @SneakyThrows (Add Custom Message to Exception) #3317

Open
andrewpolemeni opened this issue Dec 22, 2022 · 2 comments
Open

[FEATURE] @SneakyThrows (Add Custom Message to Exception) #3317

andrewpolemeni opened this issue Dec 22, 2022 · 2 comments

Comments

@andrewpolemeni
Copy link

andrewpolemeni commented Dec 22, 2022

Currently, when we annotate a function with sneaky throws it will only throw whatever exception is present or what class we defined to throw. Adding additional functionality to have a custom message along with the stack trace would be nice.

The following feature I'm proposing:

@SneakyThrows({message="some custom error message"})
public void someFunction() {
        throw new Throwable();
}
@andrewpolemeni andrewpolemeni changed the title [FEATURE] Sneaky Throws (Add Custom Message to Exception) [FEATURE] @SneakyThrows (Add Custom Message to Exception) Dec 22, 2022
@mxmlnglt
Copy link

mxmlnglt commented May 9, 2023

why not

@SneakyThrows
public void someFunction() {
        throw new Throwable("some custom error message");
}

...then?

Maybe because not all exceptions/throwables can be constructed with an error message...?

@lazeyliu
Copy link

It probably has many 'Throwable' with different messages, but only displays one custom error message

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

3 participants