Exception: InertiaRails::SSRError

Inherits:
Error
  • Object
show all
Defined in:
lib/inertia_rails/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, type: nil, hint: nil, browser_api: nil, stack: nil, source_location: nil) ⇒ SSRError

Returns a new instance of SSRError.



15
16
17
18
19
20
21
22
# File 'lib/inertia_rails/errors.rb', line 15

def initialize(message = nil, type: nil, hint: nil, browser_api: nil, stack: nil, source_location: nil)
  @type = type
  @hint = hint
  @browser_api = browser_api
  @stack = stack
  @source_location = source_location
  super(message)
end

Instance Attribute Details

#browser_apiObject (readonly)

Returns the value of attribute browser_api.



13
14
15
# File 'lib/inertia_rails/errors.rb', line 13

def browser_api
  @browser_api
end

#hintObject (readonly)

Returns the value of attribute hint.



13
14
15
# File 'lib/inertia_rails/errors.rb', line 13

def hint
  @hint
end

#source_locationObject (readonly)

Returns the value of attribute source_location.



13
14
15
# File 'lib/inertia_rails/errors.rb', line 13

def source_location
  @source_location
end

#stackObject (readonly)

Returns the value of attribute stack.



13
14
15
# File 'lib/inertia_rails/errors.rb', line 13

def stack
  @stack
end

#typeObject (readonly)

Returns the value of attribute type.



13
14
15
# File 'lib/inertia_rails/errors.rb', line 13

def type
  @type
end

Class Method Details

.from_exception(exception) ⇒ Object



35
36
37
38
39
# File 'lib/inertia_rails/errors.rb', line 35

def self.from_exception(exception)
  error = new(exception.message, type: 'connection')
  error.set_backtrace(exception.backtrace)
  error
end

.from_response(body) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/inertia_rails/errors.rb', line 24

def self.from_response(body)
  new(
    body['error'] || 'Unknown SSR error',
    type: body['type'],
    hint: body['hint'],
    browser_api: body['browserApi'],
    stack: body['stack'],
    source_location: body['sourceLocation']
  )
end