fix: clear regression and extension recovers response for error status codes
This commit is contained in:
@@ -2,6 +2,7 @@ import * as E from "fp-ts/Either"
|
|||||||
import {
|
import {
|
||||||
Interceptor,
|
Interceptor,
|
||||||
InterceptorError,
|
InterceptorError,
|
||||||
|
NetworkResponse,
|
||||||
RequestRunResult,
|
RequestRunResult,
|
||||||
} from "../../../services/interceptor.service"
|
} from "../../../services/interceptor.service"
|
||||||
import axios, { AxiosRequestConfig, CancelToken } from "axios"
|
import axios, { AxiosRequestConfig, CancelToken } from "axios"
|
||||||
@@ -51,7 +52,7 @@ async function runRequest(
|
|||||||
|
|
||||||
const timeEnd = Date.now()
|
const timeEnd = Date.now()
|
||||||
|
|
||||||
return E.right({
|
return E.right(<NetworkResponse>{
|
||||||
...res,
|
...res,
|
||||||
config: {
|
config: {
|
||||||
timeData: {
|
timeData: {
|
||||||
@@ -64,7 +65,7 @@ async function runRequest(
|
|||||||
const timeEnd = Date.now()
|
const timeEnd = Date.now()
|
||||||
|
|
||||||
if (axios.isAxiosError(e) && e.response) {
|
if (axios.isAxiosError(e) && e.response) {
|
||||||
return E.right({
|
return E.right(<NetworkResponse>{
|
||||||
...e.response,
|
...e.response,
|
||||||
config: {
|
config: {
|
||||||
timeData: {
|
timeData: {
|
||||||
|
|||||||
@@ -228,6 +228,11 @@ export class ExtensionInterceptorService
|
|||||||
|
|
||||||
return E.right(result)
|
return E.right(result)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// TODO: improve type checking
|
||||||
|
if ((e as any).response) {
|
||||||
|
return E.right((e as any).response)
|
||||||
|
}
|
||||||
|
|
||||||
return E.left(<InterceptorError>{
|
return E.left(<InterceptorError>{
|
||||||
// TODO: i18n this
|
// TODO: i18n this
|
||||||
humanMessage: {
|
humanMessage: {
|
||||||
|
|||||||
Reference in New Issue
Block a user