class Railsful::Error

The base error for this gem.

Attributes

detail[R]
status[R]

Public Class Methods

new(detail = nil, status = 400) click to toggle source

Initializer.

@param detail [String] The detailed message. @param status [Integer] The status code.

# File lib/railsful/exceptions.rb, line 12
def initialize(detail = nil, status = 400)
  @detail = detail
  @status = status
end

Public Instance Methods

as_json(_options = nil) click to toggle source

Format the error as jsonapi wants it to.

@return [Hash]

# File lib/railsful/exceptions.rb, line 20
def as_json(_options = nil)
  {
    errors: [
      {
        status: status,
        title: self.class.name.demodulize.underscore,
        detail: detail
      }
    ]
  }
end