rails-error-handling

Installation
SKILL.md

Rails Error Handling

Validation Errors

  • Use errors.add(:field, "message") to attach custom messages in validations
  • Use errors.full_messages for user display; errors.details for API/machine-readable output
  • Prefer ActiveModel::Validator or validate :method_name over inline logic
  • Always write clear, user-friendly validation messages

Exceptions & Rescue

  • Never rescue generic StandardError unless you re-raise it
  • Use rescue_from in ApplicationController for domain-specific errors (e.g., ActiveRecord::RecordNotFound)
  • Raise custom exceptions as subclasses of StandardError; include context and error codes
  • Custom error hierarchy: ApplicationError < StandardError, then AuthenticationError, AuthorizationError, ValidationError, ExternalServiceError
  • Avoid silent failures — always log unexpected exceptions with context
  • Set the correct HTTP status code whenever you render an error response

Custom Error Pages

Installs
3
First Seen
May 8, 2026
rails-error-handling — gierd-inc/dev-skills