Sha256: 79d1ec5d5223a172332cd14d16acd7ad60deabb3cf0cc4970f5038b6883c0c8e

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adamtanner-terror-0.3.0 README.markdown