From f2a04d0453b7d1e5e2725ebeb2ab487c4b452439 Mon Sep 17 00:00:00 2001 From: Benny Neugebauer Date: Sat, 16 Oct 2021 21:45:11 +0200 Subject: [PATCH] docs: Add error samples --- src/error/ErrorUtil.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/error/ErrorUtil.ts b/src/error/ErrorUtil.ts index 815d6b3e..b4613f9a 100644 --- a/src/error/ErrorUtil.ts +++ b/src/error/ErrorUtil.ts @@ -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;