Definition
Represents a registered error code.
Error codes define HTTP status codes and behavior for API errors. Retrieved via ErrorCode.find or ErrorCode.find!.
Example
ruby
error_code = Apiwork::ErrorCode.find!(:not_found)
error_code.key # => :not_found
error_code.status # => 404
error_code.attach_path? # => trueInstance Methods
#attach_path?
#attach_path?
Whether this error code attaches the request path.
Returns
Boolean
#description
#description(locale_key: nil)
The description for this error code.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
locale_key | String, nil | nil | The I18n namespace for API-specific translations. |
Returns
String
Example
ruby
error_code = Apiwork::ErrorCode.find!(:not_found)
error_code.description # => "Not Found"
error_code.description(locale_key: 'api/v1') # apiwork.apis.api/v1.error_codes.not_found.description#key
#key
The key for this error code.
Returns
Symbol
#status
#status
The status for this error code.
Returns
Integer