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

More documentation for Exception class. #4420

Merged
merged 3 commits into from May 18, 2017

Conversation

akzhan
Copy link
Contributor

@akzhan akzhan commented May 16, 2017

Heavily inspired by https://ruby-doc.org/core-2.4.0/Exception.html
[ci skip]

@ysbaddaden
Copy link
Contributor

Some notes:

  • Exception is missing an introductory header, you immediately talk about descendants, when the second line would fit (without describing what is contained);
  • don't document to_s;
  • could you keep docs around 80 chars, so they are easier to read in code?

src/exception.cr Outdated
class Exception
# Returns message of this exception.
Copy link
Contributor

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*.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

begin ... end -> begin ... end

Copy link
Contributor Author

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
Copy link
Contributor

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 ..."

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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`.
Copy link
Contributor

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.

Copy link
Contributor Author

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`.
Copy link
Contributor

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.
@akzhan
Copy link
Contributor Author

akzhan commented May 17, 2017

Strange single build job failure (not related to the change).

@RX14
Copy link
Contributor

RX14 commented May 17, 2017

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.

@akzhan akzhan closed this May 17, 2017
@akzhan
Copy link
Contributor Author

akzhan commented May 17, 2017

Reopened to retry the build.

@akzhan akzhan reopened this May 17, 2017
@akzhan
Copy link
Contributor Author

akzhan commented May 17, 2017

@RX14 looks like file sometimes isn't string. Fails here too:

      file, line, column = CallStack.decode_line_number(pc)
      if file == "??"

@akzhan akzhan closed this May 17, 2017
@akzhan
Copy link
Contributor Author

akzhan commented May 17, 2017

Ditto

@akzhan akzhan reopened this May 17, 2017
@RX14
Copy link
Contributor

RX14 commented May 17, 2017

If the build's failing due to unrelated reasons, just leave it and the core team will retry the build manually.

@akzhan
Copy link
Contributor Author

akzhan commented May 17, 2017

Thanks for the information.

@bcardiff bcardiff added this to the Next milestone May 18, 2017
@bcardiff bcardiff merged commit 3c1678e into crystal-lang:master May 18, 2017
@bcardiff
Copy link
Member

Thanks @akzhan !

@akzhan akzhan deleted the doc-Exception-class-more branch May 18, 2017 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants