-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception.go
70 lines (61 loc) · 2.15 KB
/
exception.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package jonas_chorum
import (
"encoding/xml"
"fmt"
)
// <?xml version="1.0" encoding="utf-8"?>
// <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
// <soap:Body>
// <pmsint_GetFinancialReportResponse xmlns="http://tempuri.org/RLXSOAP19/RLXSOAP19">
// <pmsint_GetFinancialReportResult>
// <ExceptionCode>70004</ExceptionCode>
// <ExceptionDescription>Access to this web method is not permitted for your user account. Method requested: pmsint_GetFinancialReport, User: </ExceptionDescription>
// </pmsint_GetFinancialReportResult>
// </pmsint_GetFinancialReportResponse>
// </soap:Body>
// </soap:Envelope>
type ExceptionBlock struct {
ExceptionCode int `xml:"ExceptionCode"`
ExceptionDescription string `xml:"ExceptionDescription"`
ResponseCode int `xml:"ResponseCode"`
ResponseDescription string `xml:"ResponseDescription"`
}
func (eb ExceptionBlock) Error() string {
return fmt.Sprintf("%d: %s", eb.ExceptionCode, eb.ExceptionDescription)
}
// <Content>
// <Header>
// <BucketType>ERROR</BucketType>
// <APIType>NA</APIType>
// <APIVersion>NA</APIVersion>
// <SecurityToken>NA</SecurityToken>
// <Internal>NA</Internal>
// <CustomDataA></CustomDataA>
// <CustomDataB></CustomDataB>
// <CustomDataC></CustomDataC>
// <CustomDataD></CustomDataD>
// </Header>
// <Parameters />
// <Body>
// <Status>Failure</Status>
// <StatusNote>Hotel Disallowed</StatusNote>
// </Body>
// </Content>
type BodyFailure struct {
XMLName xml.Name `xml:"Content"`
Header JCHeader `xml:"Header"`
Parameters JCParameters `xml:"Parameters"`
Body struct {
Status string `xml:"Status"`
StatusNote string `xml:"StatusNote"`
} `xml:"Body"`
}
func (b BodyFailure) Error() string {
if b.Header.BucketType == "ERROR" || b.Body.Status == "Failure" {
return fmt.Sprintf("%s: %s", b.Header.BucketType, b.Body.StatusNote)
}
if b.Parameters.Error != "" {
return fmt.Sprintf("%s: %s", b.Header.BucketType, b.Parameters.Error)
}
return ""
}