Class: ServiceStack::ResponseStatus
- Inherits:
-
Object
- Object
- ServiceStack::ResponseStatus
- 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
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#message ⇒ Object
Returns the value of attribute message.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
Class Method Summary collapse
Instance Method Summary collapse
-
#field_error(field_name) ⇒ Object
The validation error message for the field, matched case-insensitively.
-
#get_field_error(field_name) ⇒ Object
The ResponseError for the field, matched case-insensitively.
Methods included from DTO
#==, included, #initialize, #inspect, #to_hash, #to_json
Instance Attribute Details
#error_code ⇒ Object
Returns the value of attribute error_code.
25 26 27 |
# File 'lib/servicestack/types.rb', line 25 def error_code @error_code end |
#errors ⇒ Object
Returns the value of attribute errors.
25 26 27 |
# File 'lib/servicestack/types.rb', line 25 def errors @errors end |
#message ⇒ Object
Returns the value of attribute message.
25 26 27 |
# File 'lib/servicestack/types.rb', line 25 def @message end |
#meta ⇒ Object
Returns the value of attribute meta.
25 26 27 |
# File 'lib/servicestack/types.rb', line 25 def @meta end |
#stack_trace ⇒ Object
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
.properties ⇒ Object
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&. 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 |