Skip to content

New exception classes #837

Open
Open
@marcandre

Description

@marcandre

Prefer the use of exceptions from the standard library over introducing new exception classes.

I feel this is not quite accurate.

Indeed, a gem should use standard library exceptions in case the gem is called with invalid inputs (e.g. TypeError if called with an Integer instead of a String, ArgumentError, IndexError, etc.). Typically these are never rescued.

But when something proper to the gem happens, instead of raising a RuntimeError it should have its own subclasses of StandardError for that gem (with potentially a base class for the gem). E.g. ::Parser::SyntaxError, ::Parser::ClobberingError. Typically these may be rescued by the dependents of the gem.

May I amend the guide?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions