Class: ViewModel::ErrorView::ExceptionDetailView

Inherits:
ViewModel
  • Object
show all
Defined in:
lib/view_model/error_view.rb

Constant Summary

Constants inherited from ViewModel

BULK_UPDATES_ATTRIBUTE, BULK_UPDATE_ATTRIBUTE, BULK_UPDATE_TYPE, ID_ATTRIBUTE, MIGRATED_ATTRIBUTE, NEW_ATTRIBUTE, REFERENCE_ATTRIBUTE, TYPE_ATTRIBUTE, VERSION_ATTRIBUTE

Instance Method Summary collapse

Methods inherited from ViewModel

#==, accepts_schema_version?, add_view_alias, attribute, attributes, #blame_reference, #context_for_child, deserialization_includes, deserialize_context_class, deserialize_from_view, deserialize_members_from_view, eager_includes, encode_json, extract_reference_metadata, extract_reference_only_metadata, extract_viewmodel_metadata, #hash, #id, inherited, #initialize, initialize_as_viewmodel, is_update_hash?, lock_attribute_inheritance, member_names, #model, new_deserialize_context, new_serialize_context, preload_for_serialization, #preload_for_serialization, root!, root?, schema_hash, schema_versions, #serialize, serialize, serialize_as_reference, serialize_context_class, serialize_from_cache, serialize_to_hash, #serialize_to_hash, #stable_id?, #to_json, #to_reference, #validate!, #view_name

Constructor Details

This class inherits a constructor from ViewModel

Instance Method Details

#serialize_view(json, serialize_context: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/view_model/error_view.rb', line 12

def serialize_view(json, serialize_context: nil)
  json.set! :class, exception.class.name
  json.backtrace exception.backtrace

  json.cause do
    cause = exception.cause
    next json.null! unless cause

    json.set! :class, cause.class.name
    json.backtrace cause.backtrace
  end

  json.context do
    next json.null! unless exception.respond_to?(:to_honeybadger_context)

    json.merge! exception.to_honeybadger_context
  end
end