Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adamtanner-terror

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adamtanner-terror

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

!! TERROR !!

Terror allows you to define your errors/exceptions in a pretty run-of-the-mill style DSL.

Reasons Terror exists:

  • Because defining errors as subclasses of StandardError looks ugly.
  • Also, because I wanted to make a pseudo-useful DSL.

How to use Terror:

For times where all you need is a pretty name to raise.

exceptions :exceptionally, "exceptional"

If you need a little more control over your exceptions you can use a block. The methods inside the block become camel-cased exceptions where the method name is the exception name.

exceptions do
  there_is_no_exception "You did wrong. There is no exception!"
end

The argument passed to the method is the message you want to use when you raise the exception. For the example above you would do:

raise ThereIsNoException, ThereIsNoException.message

If you need even more control over your exceptions and want to add custom functionality you can pass the method a block and insert whatever code you want available for the exception.

exceptions do
  my_exception do   
    def handle_my_exception()
      return "Check that out, I can add my own methods!"
    end
  end
end

And, of course, all of these can be done together in the same exceptions method if you need more, or less, functionality for different exceptions.

Things I'd Like to Get Around to Doing:

  • Making this a gem.
  • Writing tests. (In progress)

That's all folks.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc