diff --git a/src/core/request/index.ts b/src/core/request/index.ts index a7866e540..37863d6cc 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) === false ? undefined : log.error('request', err)); 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