aboutsummaryrefslogtreecommitdiff
path: root/pkg/navitia_api_client/error.go
blob: 31080de091d2f1dfcdf6974a54f00d15d397c22e (plain)
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 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,
	}
}