Compare commits
6 commits
511b7a940c
...
1038bad7d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1038bad7d5 | ||
|
|
f9555e47c7 | ||
|
|
452a09fff7 | ||
|
|
46b0fc241c | ||
|
|
480447e9a6 | ||
|
|
3c44f185b0 |
|
|
@ -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{}, fmt.Errorf("%w: %s", ErrInvalidConvert, toCode)
|
return RateDTO{}, ErrInvalidConvert // Invalid convert parameter
|
||||||
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{}, fmt.Errorf("%w: %s", ErrUnknownSymbol, fromCode)
|
return RateDTO{}, ErrUnknownSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract rate from response
|
// Extract rate from response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue