Class: ServiceStack::ResponseStatus

Inherits:
Object
  • Object
show all
Includes:
DTO
Defined in:
lib/servicestack/types.rb

Overview

ServiceStack's structured error, returned in the responseStatus property of failed API Responses.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DTO

#==, included, #initialize, #inspect, #to_hash, #to_json

Instance Attribute Details

#error_codeObject

Returns the value of attribute error_code.



25
26
27
# File 'lib/servicestack/types.rb', line 25

def error_code
  @error_code
end

#errorsObject

Returns the value of attribute errors.



25
26
27
# File 'lib/servicestack/types.rb', line 25

def errors
  @errors
end

#messageObject

Returns the value of attribute message.



25
26
27
# File 'lib/servicestack/types.rb', line 25

def message
  @message
end

#metaObject

Returns the value of attribute meta.



25
26
27
# File 'lib/servicestack/types.rb', line 25

def meta
  @meta
end

#stack_traceObject

Returns the value of attribute stack_trace.



25
26
27
# File 'lib/servicestack/types.rb', line 25

def stack_trace
  @stack_trace
end

Class Method Details

.propertiesObject



27
28
29
30
31
32
33
34
35
# File 'lib/servicestack/types.rb', line 27

def self.properties
  {
    error_code: { name: 'errorCode' },
    message: { name: 'message' },
    stack_trace: { name: 'stackTrace' },
    errors: { name: 'errors', type: [ResponseError] },
    meta: { name: 'meta' },
  }
end

Instance Method Details

#field_error(field_name) ⇒ Object

The validation error message for the field, matched case-insensitively.



38
39
40
41
# File 'lib/servicestack/types.rb', line 38

def field_error(field_name)
  error = get_field_error(field_name)
  error&.message
end

#get_field_error(field_name) ⇒ Object

The ResponseError for the field, matched case-insensitively.



44
45
46
# File 'lib/servicestack/types.rb', line 44

def get_field_error(field_name)
  (errors || []).find { |x| x.field_name.to_s.casecmp?(field_name.to_s) }
end