From a9b527d686e833b41fd93231846757fd2d11e524 Mon Sep 17 00:00:00 2001 From: bonkalol Date: Fri, 28 Feb 2025 23:30:03 +0300 Subject: [PATCH 1/2] Added ignore error option --- src/core/request/index.ts | 2 +- src/core/request/interface.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/request/index.ts b/src/core/request/index.ts index a7866e540..a1c250ba4 100644 --- a/src/core/request/index.ts +++ b/src/core/request/index.ts @@ -382,7 +382,7 @@ function request( } }) - .catch((err) => log.error('request', err)); + .catch((err) => opts.logError?.(err) ? log.error('request', err) : undefined); resolve(ctx.wrapRequest(resultPromise)); diff --git a/src/core/request/interface.ts b/src/core/request/interface.ts index 53cf64e0a..29b02ca56 100644 --- a/src/core/request/interface.ts +++ b/src/core/request/interface.ts @@ -522,6 +522,15 @@ export interface CreateRequestOptions { */ important?: boolean; + /** + * By default, request errors are sent to the logger. However, sometimes + * certain errors should not be logged. To disable logging for specific errors, + * use this parameter. If it returns `false`, the error will not be logged. + * + * @param error - The error that occurred during the request. + */ + logError?(error?: RequestError | unknown): boolean; + /** * A request engine to use. * The engine - is a simple function that takes request parameters and returns an abortable promise resolved with the From 5c581eeaf89e5bf006567b2038773df572586e62 Mon Sep 17 00:00:00 2001 From: bonkalol Date: Fri, 28 Feb 2025 23:39:43 +0300 Subject: [PATCH 2/2] fixed condition --- src/core/request/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/request/index.ts b/src/core/request/index.ts index a1c250ba4..37863d6cc 100644 --- a/src/core/request/index.ts +++ b/src/core/request/index.ts @@ -382,7 +382,7 @@ function request( } }) - .catch((err) => opts.logError?.(err) ? log.error('request', err) : undefined); + .catch((err) => opts.logError?.(err) === false ? undefined : log.error('request', err)); resolve(ctx.wrapRequest(resultPromise));