aboutsummaryrefslogtreecommitdiff
path: root/pkg/navitia_api_client/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/navitia_api_client/error.go')
-rw-r--r--pkg/navitia_api_client/error.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkg/navitia_api_client/error.go b/pkg/navitia_api_client/error.go
new file mode 100644
index 0000000..31080de
--- /dev/null
+++ b/pkg/navitia_api_client/error.go
@@ -0,0 +1,70 @@
+package navitia_api_client
+
+import "fmt"
+
+// navitia api query error
+type ApiError struct {
+ code int
+ request string
+}
+
+func (e *ApiError) Error() string {
+ return fmt.Sprintf("Navitia Api error return code %d - %s", e.code, e.request)
+}
+
+func newApiError(code int, request string) error {
+ return &ApiError{
+ code: code,
+ request: request,
+ }
+}
+
+// http client error
+type HttpClientError struct {
+ msg string
+ err error
+}
+
+func (e *HttpClientError) Error() string { return fmt.Sprintf("Navitia HttpClient error %s", e.msg) }
+func (e *HttpClientError) Unwrap() error { return e.err }
+
+func newHttpClientError(msg string, err error) error {
+ return &HttpClientError{
+ msg: msg,
+ err: err,
+ }
+}
+
+// json decoding error
+type JsonDecodeError struct {
+ msg string
+ err error
+}
+
+func (e *JsonDecodeError) Error() string { return fmt.Sprintf("Navitia JsonDecode error %s", e.msg) }
+func (e *JsonDecodeError) Unwrap() error { return e.err }
+
+func newJsonDecodeError(msg string, err error) error {
+ return &JsonDecodeError{
+ msg: msg,
+ err: err,
+ }
+}
+
+// date parsing error
+type DateParsingError struct {
+ date string
+ err error
+}
+
+func (e *DateParsingError) Error() string {
+ return fmt.Sprintf("Navitia date parsing error %s", e.date)
+}
+func (e *DateParsingError) Unwrap() error { return e.err }
+
+func newDateParsingError(date string, err error) error {
+ return &DateParsingError{
+ date: date,
+ err: err,
+ }
+}