Module: WscSdk::Errors

Defined in:
lib/wsc_sdk/errors.rb

Overview

Enumerate the errors that can be generated by the SDK

Constant Summary collapse

INVALID_ATTRIBUTES =

Error returned when the model does not validate.

{
  meta: {
    status:       422,
    code:         "ERR-422-InvalidAttributes",
    title:        "Invalid Attributes",
    message:      "The model has invalid attribute values assigned to it.  Check the `WscSdk::Model#errors` property for more details.",
    description:  ""
  }
}
INVALID_PAYLOAD =

Error returned if the data returned from the API is not valid JSON.

{
  meta: {
    status:       422,
    code:         "ERR-422-PayloadInvalid",
    title:        "Payload Invalid",
    message:      "The API request received an invalid payload.",
    description:  "Turn on logging in DEBUG mode for more details about the issue."
  }
}
MODEL_DOES_NOT_EXIST =

Error returned when the model is attempting an update, but it doesn't have a primary key.

{
  meta: {
    status:       422,
    code:         "ERR-422-ModelDoesNotExist",
    title:        "Model Does Not Exist",
    message:      "You are attempting to access or update a record that does not exist yet. Try creating it first.",
    description:  ""
  }
}
MODEL_EXISTS =

Error returned when the model is attempting to create, but it already has a primary key.

{
  meta: {
    status:       422,
    code:         "ERR-422-ModelExists",
    title:        "Model Exists",
    message:      "You are attempting to create a record that already exists. Try updating the it.",
    description:  ""
  }
}

Class Method Summary collapse

Class Method Details

.invalid_attributes(endpoint) ⇒ WscSdk::Models::Error

Build an INVALID_ATTRIBUTES error model object.

Parameters:

Returns:



66
67
68
69
70
# File 'lib/wsc_sdk/errors.rb', line 66

def self.invalid_attributes(endpoint)
  error = WscSdk::Models::Error.new(endpoint)
  error.ingest_attributes(INVALID_ATTRIBUTES, write_to_read_only: true, mark_clean: true)
  error
end

.invalid_payload(endpoint) ⇒ WscSdk::Models::Error

Build an INVALID_PAYLOAD error model object.

Parameters:

Returns:



80
81
82
83
84
# File 'lib/wsc_sdk/errors.rb', line 80

def self.invalid_payload(endpoint)
  error = WscSdk::Models::Error.new(endpoint)
  error.ingest_attributes(INVALID_PAYLOAD, write_to_read_only: true, mark_clean: true)
  error
end

.model_does_not_exist(endpoint) ⇒ WscSdk::Models::Error

Build an RECORD_DOES_NOT_EXIST error model object.

Parameters:

Returns:



94
95
96
97
98
# File 'lib/wsc_sdk/errors.rb', line 94

def self.model_does_not_exist(endpoint)
  error = WscSdk::Models::Error.new(endpoint)
  error.ingest_attributes(MODEL_DOES_NOT_EXIST, write_to_read_only: true, mark_clean: true)
  error
end

.model_exists(endpoint) ⇒ WscSdk::Models::Error

Build an RECORD_EXISTS error model object.

Parameters:

Returns:



108
109
110
111
112
# File 'lib/wsc_sdk/errors.rb', line 108

def self.model_exists(endpoint)
  error = WscSdk::Models::Error.new(endpoint)
  error.ingest_attributes(MODEL_EXISTS, write_to_read_only: true, mark_clean: true)
  error
end