Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
docs: Add error samples
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Oct 16, 2021
1 parent 44e60f8 commit f2a04d0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/error/ErrorUtil.ts
Expand Up @@ -8,6 +8,18 @@ export function gotRateLimited(error: AxiosError): boolean {
return error.response?.status === 429;
}

/**
* Possible errors returned from Coinbase Pro API:
* { message: 'size is too accurate. Smallest unit is 0.00000001' }
* { message: 'size is too small. Minimum size is 0.10000000' }
* { message: 'Insufficient funds' }
* { message: 'NotFound' }
*
* Error handling in the official API client:
* https://github.com/coinbase/coinbase-pro-trading-toolkit/blob/e95c76eb43bda1fd86379612644a79b02948c17a/src/core/Trader.ts#L122-L126
*
* @param error Error response wrapped by "axios" request library
*/
export function getErrorMessage(error: AxiosError): string {
const responseWithErrorMessage = error as AxiosError<{message: string}>;
return responseWithErrorMessage.response?.data.message || error.message;
Expand Down

0 comments on commit f2a04d0

Please sign in to comment.