* Maps axios HTTP errors to appropriate error classes
(error: AxiosError)
| 134 | * Maps axios HTTP errors to appropriate error classes |
| 135 | */ |
| 136 | protected mapAxiosError(error: AxiosError): BaseError { |
| 137 | const status = error.response?.status; |
| 138 | const message = this.extractErrorMessage(error); |
| 139 | const data = error.response?.data; |
| 140 | |
| 141 | // Network/connection errors |
| 142 | if (!status) { |
| 143 | if (error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT') { |
| 144 | return new NetworkError( |
| 145 | `Request timeout: ${message}`, |
| 146 | this.exchangeName |
| 147 | ); |
| 148 | } |
| 149 | return new ExchangeNotAvailable( |
| 150 | `Exchange unreachable: ${message}`, |
| 151 | this.exchangeName |
| 152 | ); |
| 153 | } |
| 154 | |
| 155 | return this.mapByStatusCode(status, message, data, error.response); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Maps an HTTP status code to the appropriate error class |
no test coverage detected