lib/xeroizer/exceptions.rb in xeroizer-2.15.9 vs lib/xeroizer/exceptions.rb in xeroizer-2.16.0

- old
+ new

@@ -11,11 +11,14 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. module Xeroizer - class ApiException < StandardError + + class XeroizerError < StandardError; end + + class ApiException < XeroizerError attr_reader :type, :message, :xml, :parsed_xml, :request_body def initialize(type, message, xml, parsed_xml, request_body) @type = type @@ -39,11 +42,11 @@ [] end end - class UnparseableResponse < StandardError + class UnparseableResponse < XeroizerError def initialize(root_element_name) @root_element_name = root_element_name end @@ -51,11 +54,11 @@ "A root element of #{@root_element_name} was returned, and we don't understand that!" end end - class ObjectNotFound < StandardError + class ObjectNotFound < XeroizerError def initialize(api_endpoint) @api_endpoint = api_endpoint end @@ -63,15 +66,15 @@ "Couldn't find object for API Endpoint #{@api_endpoint}" end end - class InvoiceNotFoundError < StandardError; end + class InvoiceNotFoundError < XeroizerError; end - class CreditNoteNotFoundError < StandardError; end + class CreditNoteNotFoundError < XeroizerError; end - class MethodNotAllowed < StandardError + class MethodNotAllowed < XeroizerError def initialize(klass, method) @klass = klass @method = method end @@ -80,11 +83,11 @@ "Method #{@method} not allowed on #{@klass}" end end - class RecordKeyMustBeDefined < StandardError + class RecordKeyMustBeDefined < XeroizerError def initialize(possible_keys) @possible_keys = possible_keys end @@ -92,11 +95,11 @@ "One of the keys #{@possible_keys.join(', ')} need to be defined to update the record." end end - class SettingTotalDirectlyNotSupported < StandardError + class SettingTotalDirectlyNotSupported < XeroizerError def initialize(attribute_name) @attribute_name = attribute_name end @@ -104,11 +107,11 @@ "Can't set the total #{@attribute_name} directly as this is calculated automatically." end end - class InvalidAttributeInWhere < StandardError + class InvalidAttributeInWhere < XeroizerError def initialize(model_name, attribute_name) @model_name = model_name @attribute_name = attribute_name end @@ -117,11 +120,11 @@ "#{@attribute_name} is not an attribute of #{@model_name}." end end - class AssociationTypeMismatch < StandardError + class AssociationTypeMismatch < XeroizerError def initialize(model_class, actual_class) @model_class = model_class @actual_class = actual_class end @@ -130,10 +133,10 @@ "#{@model_class} expected, got #{@actual_class}" end end - class CannotChangeInvoiceStatus < StandardError + class CannotChangeInvoiceStatus < XeroizerError def initialize(invoice, new_status) @invoice = invoice @new_status = new_status end