Compare commits
6 commits
1038bad7d5
...
511b7a940c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
511b7a940c | ||
|
|
79795215ac | ||
|
|
d71b5ff2b4 | ||
|
|
12b774312f | ||
|
|
cb69b72ce3 | ||
|
|
9a9a6b338b |
|
|
@ -89,7 +89,7 @@ func (c *Client) tryGetRate(ctx context.Context, fromCode, toCode string) (RateD
|
||||||
if resp.StatusCode() != 200 {
|
if resp.StatusCode() != 200 {
|
||||||
switch resp.StatusCode() {
|
switch resp.StatusCode() {
|
||||||
case 400:
|
case 400:
|
||||||
return RateDTO{}, ErrInvalidConvert // Invalid convert parameter
|
return RateDTO{}, fmt.Errorf("%w: %s", ErrInvalidConvert, toCode)
|
||||||
case 401:
|
case 401:
|
||||||
return RateDTO{}, fmt.Errorf("%w: unauthorized - bad or missing API key", ErrAPIError)
|
return RateDTO{}, fmt.Errorf("%w: unauthorized - bad or missing API key", ErrAPIError)
|
||||||
default:
|
default:
|
||||||
|
|
@ -99,7 +99,7 @@ func (c *Client) tryGetRate(ctx context.Context, fromCode, toCode string) (RateD
|
||||||
|
|
||||||
// Check if data is empty - invalid currency
|
// Check if data is empty - invalid currency
|
||||||
if len(response.Data) == 0 {
|
if len(response.Data) == 0 {
|
||||||
return RateDTO{}, ErrUnknownSymbol
|
return RateDTO{}, fmt.Errorf("%w: %s", ErrUnknownSymbol, fromCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract rate from response
|
// Extract rate from response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue