Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Sep 18, 2024
1 parent c6d88c6 commit 5771637
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/services/logger/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { AxiosError } from 'axios'
import type {
AxiosError,
AxiosResponse,
InternalAxiosRequestConfig,
} from 'axios'

import type APICallContextData from './context'

Expand All @@ -11,10 +15,10 @@ interface APICallContextDataWithErrorMessage extends APICallContextData {

const getMessage = (error: AxiosError): string => error.message

const withErrorMessage = (
base: new (...args: any[]) => APICallContextData,
const withErrorMessage = <T extends AxiosResponse | InternalAxiosRequestConfig>(
base: new (arg?: T) => APICallContextData,
error: AxiosError,
): new (...args: unknown[]) => APICallContextDataWithErrorMessage =>
): new (arg?: T) => APICallContextDataWithErrorMessage =>
class extends base {
public readonly errorMessage = getMessage(error)
}
Expand Down

0 comments on commit 5771637

Please sign in to comment.