-
Notifications
You must be signed in to change notification settings - Fork 211
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
Could build_runner provide a stacktrace when builders throw an exception? #3585
Comments
If you pass |
The main issue is, I have no control over what issue authors write. Take the issue linked for example: Besides asking for more information, I can't do much. If stacktraces were included by default, when users report issues, I'd be much more likely to be able to fix the issue in a short time-frame. |
@jakemac53 - WDYT about printing the stack trace by default for subtypes of I think it's intended behavior that a builder author can throw an |
Closes #3585 The default logging omits stack traces by default and prints them only in verbose mode. This is intended to allow builder implementations to cease execution and log a user friendly message by throwing a single `Exception` with a custom `toString()`. When a builder or utility library has an implementation bug leading to an `Error` the stack trace is much more likely to be useful information for debugging, and worth including by default.
SGTM |
In that case we'd want to make InvalidSourceGenerationError to be an exception instead https://pub.dev/documentation/source_gen/latest/source_gen/InvalidGenerationSourceError-class.html I think many code generators rely on it |
See dart-lang/build#3585 Rename to `InvalidGenerationSource` and change to a subtype of `Exception`. This class is not thrown to indicate a programming error in the code that is running, it is thrown to indicate an error in the code under analysis. It was originally implemented without a super type and the name ending in "Error" was not specifically discussed, but it was intended to convey an "error in build input", not an error in the builder implementation (where it is thrown). Later a lint required it to be a subtype of either `Error` or `Exception`, and the `Error` supertype was chosen without discussion because of the name, even though it's not thrown as an `Error` in the sense where that distinction matters. Add a type alias for the exception with the old name. This can be deprecated whenever we have the bandwidth to handle the cleanup, but it will not be deprecated immediately. Change from `extends Error` to `implements Exception`. This is technically breaking, but it is unlikely to make a significant impact in real world usage scenarios. It may impact how the error surfaces to end users in some places.
See dart-lang/build#3585 Rename to `InvalidGenerationSource` and change to a subtype of `Exception`. This class is not thrown to indicate a programming error in the code that is running, it is thrown to indicate an error in the code under analysis. It was originally implemented without a super type and the name ending in "Error" was not specifically discussed, but it was intended to convey an "error in build input", not an error in the builder implementation (where it is thrown). Later a lint required it to be a subtype of either `Error` or `Exception`, and the `Error` supertype was chosen without discussion because of the name, even though it's not thrown as an `Error` in the sense where that distinction matters. Add a type alias for the exception with the old name. This can be deprecated whenever we have the bandwidth to handle the cleanup, but it will not be deprecated immediately. Change from `extends Error` to `implements Exception`. This is technically breaking, but it is unlikely to make a significant impact in real world usage scenarios. It may impact how the error surfaces to end users in some places.
Closes #3585 The default logging omits stack traces by default and prints them only in verbose mode. This is intended to allow builder implementations to cease execution and log a user friendly message by throwing a single `Exception` with a custom `toString()`. When a builder or utility library has an implementation bug leading to an `Error` the stack trace is much more likely to be useful information for debugging, and worth including by default.
) See #3585 Rename to `InvalidGenerationSource` and change to a subtype of `Exception`. This class is not thrown to indicate a programming error in the code that is running, it is thrown to indicate an error in the code under analysis. It was originally implemented without a super type and the name ending in "Error" was not specifically discussed, but it was intended to convey an "error in build input", not an error in the builder implementation (where it is thrown). Later a lint required it to be a subtype of either `Error` or `Exception`, and the `Error` supertype was chosen without discussion because of the name, even though it's not thrown as an `Error` in the sense where that distinction matters. Add a type alias for the exception with the old name. This can be deprecated whenever we have the bandwidth to handle the cleanup, but it will not be deprecated immediately. Change from `extends Error` to `implements Exception`. This is technically breaking, but it is unlikely to make a significant impact in real world usage scenarios. It may impact how the error surfaces to end users in some places.
) See #3585 Rename to `InvalidGenerationSource` and change to a subtype of `Exception`. This class is not thrown to indicate a programming error in the code that is running, it is thrown to indicate an error in the code under analysis. It was originally implemented without a super type and the name ending in "Error" was not specifically discussed, but it was intended to convey an "error in build input", not an error in the builder implementation (where it is thrown). Later a lint required it to be a subtype of either `Error` or `Exception`, and the `Error` supertype was chosen without discussion because of the name, even though it's not thrown as an `Error` in the sense where that distinction matters. Add a type alias for the exception with the old name. This can be deprecated whenever we have the bandwidth to handle the cleanup, but it will not be deprecated immediately. Change from `extends Error` to `implements Exception`. This is technically breaking, but it is unlikely to make a significant impact in real world usage scenarios. It may impact how the error surfaces to end users in some places.
Hello!
One inconvenience I've had for a while is, if a code-generator fails, no stacktrace is available.
That makes debugging quite difficult.
For example, I've received the following issue: rrousselGit/riverpod#2798:
The user provided their console logs. But the error by itself is unhelpful.
The text was updated successfully, but these errors were encountered: