-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
More documentation for Exception class. #4420
More documentation for Exception class. #4420
Conversation
Heavily inspired by https://ruby-doc.org/core-2.4.0/Exception.html [ci skip]
Some notes:
|
src/exception.cr
Outdated
class Exception | ||
# Returns message of this exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is rather useless without a description of what the message is used for.
src/exception.cr
Outdated
def backtrace? | ||
@callstack.try &.printable_backtrace | ||
end | ||
|
||
# Appends a `message` of this exception to the given *io*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think that this to_s should be documented because often users want inspect_with_backtrace instead.
* Add introductory header to `Exception` class. * Add description for `DivisionByZero` class. * Drop documentation to *message* and *to_s*. * Other minor updates.
src/exception.cr
Outdated
# Represents errors that occur during application execution. | ||
# | ||
# Descendants of class Exception are used to communicate between raise and | ||
# rescue statements in begin ... end blocks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
begin ... end -> begin ... end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
src/exception.cr
Outdated
@@ -2,18 +2,39 @@ require "callstack" | |||
|
|||
CallStack.skip(__FILE__) | |||
|
|||
# Represents errors that occur during application execution. | |||
# | |||
# Descendants of class Exception are used to communicate between raise and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "Exception and it's descendants are used ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception itself should not be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is used everywhere: https://github.com/crystal-lang/crystal/blob/master/src/raise.cr#L189.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. OK :)
src/exception.cr
Outdated
# The backtrace is an array of strings, each containing | ||
# “0xAddress: Function at File Line Column”. | ||
# | ||
# See also: `CallStack#decode_backtrace`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CallStack
is explicitly excluded from the docs so this "See also" probably won't help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, removed.
src/exception.cr
Outdated
# The backtrace is an array of strings, each containing | ||
# “0xAddress: Function at File Line Column”. | ||
# | ||
# See also: `CallStack#decode_backtrace`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
* begin ... end -> `begin ... end` * "Exception and it's descendants are used ..." * Don't mention about CallStack class that excluded from docs.
Strange single build job failure (not related to the change). |
It looks like crystal's specs have an intermittent 32bit segfault in LLVM::Context#finalize. I think i've seen it before in another travis build. |
Reopened to retry the build. |
@RX14 looks like file, line, column = CallStack.decode_line_number(pc)
if file == "??" |
Ditto |
If the build's failing due to unrelated reasons, just leave it and the core team will retry the build manually. |
Thanks for the information. |
Thanks @akzhan ! |
Heavily inspired by https://ruby-doc.org/core-2.4.0/Exception.html
[ci skip]