Skip to content

Instantly share code, notes, and snippets.

@aelindeman
Created May 5, 2017 14:53
Show Gist options
  • Save aelindeman/1537c93cf386354999a30f5552ce6f47 to your computer and use it in GitHub Desktop.
Save aelindeman/1537c93cf386354999a30f5552ce6f47 to your computer and use it in GitHub Desktop.
ruby error with extra field
# error class:
class AttachableError < StandardError
attr_reader :data
def initialize(message = nil, data = nil)
@message = message
@data = data
end
def to_s
@message || 'Default error message'
end
end
# usage:
raise AttachableError.new('my message', data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment