/
exceptions.rb
47 lines (34 loc) · 1.13 KB
/
exceptions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module XeroGateway
class ApiException < StandardError
def initialize(type, message, request_xml, response_xml)
@type = type
@message = message
@request_xml = request_xml
@response_xml = response_xml
end
attr_reader :request_xml, :response_xml
def message
"#{@type}: #{@message} \n Generated by the following XML: \n #{@response_xml}"
end
end
class UnparseableResponse < StandardError
def initialize(root_element_name)
@root_element_name = root_element_name
end
def message
"A root element of #{@root_element_name} was returned, and we don't understand that!"
end
end
class ObjectNotFound < StandardError
def initialize(api_endpoint)
@api_endpoint = api_endpoint
end
def message
"Couldn't find object for API Endpoint #{@api_endpoint}"
end
end
class InvoiceNotFoundError < StandardError; end
class BankTransactionNotFoundError < StandardError; end
class CreditNoteNotFoundError < StandardError; end
class ManualJournalNotFoundError < StandardError; end
end