Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/jsonapi/error.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module JSONAPI
class Error
attr_accessor :title, :detail, :id, :href, :code, :source, :links, :status
attr_accessor :title, :detail, :id, :href, :code, :source, :links, :status, :meta

def initialize(options = {})
@title = options[:title]
Expand All @@ -16,6 +16,7 @@ def initialize(options = {})
@links = options[:links]

@status = Rack::Utils::SYMBOL_TO_STATUS_CODE[options[:status]].to_s
@meta = options[:meta]
end
end

Expand Down
9 changes: 8 additions & 1 deletion lib/jsonapi/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ def initialize(exception)
end

def errors
unless Rails.env.prod?
meta = Hash.new
meta[:exception] = exception.message
meta[:backtrace] = exception.backtrace
end

[JSONAPI::Error.new(code: JSONAPI::INTERNAL_SERVER_ERROR,
status: :internal_server_error,
title: 'Internal Server Error',
detail: 'Internal Server Error')]
detail: 'Internal Server Error',
meta: meta)]
end
end

Expand Down