Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby Argument Error with Custom Message

If you want to raise an argument error with a clearer message

def process_thing(account: nil, thing: nil)
  raise(ArgumentError.new("processing requires an account")) if account.blank?
  raise(ArgumentError.new("Must have a Thing to process")) if thing.blank?
  # ... Do the actual work
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.