Reason #37 • February 6th, 2026

raise "whatever I feel like I wanna raise"

If you're raising errors which you expect someone will want to rescue and handle, it's best to raise an actual StandardError subclass. But if you just want to raise something as a quick assertion to guard against an unexpected condition, raising a String is fine.

Ruby
# test.rb

def create_user(parsed_json)
  raise "Missing name in #{parsed_json}" unless parsed_json["name"]

  # ...
end

create_user("age" => 23)

# test.rb:4:in 'Object#create_user':
#   Missing name in {"age" => 23} (RuntimeError)
#	from test.rb:10:in '<main>'
      
JavaScript
// test.js

function createUser(parsedJson) {
  if (!parsedJson.name) {
    throw new Error(`Missing name in ${JSON.stringify(parsedJson)}`);
  }

  // ...
}

createUser({ age: 23 });

// test.js:5
//   throw new Error(`Missing name in ${JSON.stringify(parsedJson)}`);
//   ^
//
// Error: Missing name in {"age":23}
//     at createUser (test.js:5:11)
//     at Object. (test.js:11:1)
//     at Module._compile (node:internal/modules/cjs/loader:1760:14)
//     at Object..js (node:internal/modules/cjs/loader:1892:10)
//     at Module.load (node:internal/modules/cjs/loader:1480:32)
//     at Module._load (node:internal/modules/cjs/loader:1299:12)
//     at TracingChannel.traceSync (node:diagnostics_channel:328:14)
//     at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
//     at Module.executeUserEntryPoint [as runMain] (...:154:5)
//     at node:internal/main/run_main_module:33:47
      

In JavaScript it's possible to throw a simple string as well, but if we do that we don't get a stack trace, which makes debugging much harder. In Ruby, we get a stack trace even when we raise a simple string, since the raise keyword automatically creates a RuntimeError with the given string as its message, making it fully compatible with error handling tools and services.

So don't be afraid of raising a bit of "hell" when you're out there Ruby programming and don't let anyone else tell you otherwise