convert axios error to taler error
This commit is contained in:
parent
92873710f1
commit
87749371dd
@ -26,7 +26,7 @@ import {
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
} from "../util/http";
|
} from "../util/http";
|
||||||
import { RequestThrottler } from "../util/RequestThrottler";
|
import { RequestThrottler } from "../util/RequestThrottler";
|
||||||
import Axios from "axios";
|
import Axios, { AxiosResponse } from "axios";
|
||||||
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
import { TalerErrorCode } from "../TalerErrorCode";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
@ -70,16 +70,28 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
|||||||
if (typeof opt?.timeout?.d_ms === "number") {
|
if (typeof opt?.timeout?.d_ms === "number") {
|
||||||
timeout = opt.timeout.d_ms;
|
timeout = opt.timeout.d_ms;
|
||||||
}
|
}
|
||||||
const resp = await Axios({
|
let resp: AxiosResponse;
|
||||||
method,
|
try {
|
||||||
url: url,
|
resp = await Axios({
|
||||||
responseType: "text",
|
method,
|
||||||
headers: opt?.headers,
|
url: url,
|
||||||
validateStatus: () => true,
|
responseType: "text",
|
||||||
transformResponse: (x) => x,
|
headers: opt?.headers,
|
||||||
data: body,
|
validateStatus: () => true,
|
||||||
timeout,
|
transformResponse: (x) => x,
|
||||||
});
|
data: body,
|
||||||
|
timeout,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
throw OperationFailedError.fromCode(
|
||||||
|
TalerErrorCode.WALLET_NETWORK_ERROR,
|
||||||
|
`${e.message}`,
|
||||||
|
{
|
||||||
|
requestUrl: url,
|
||||||
|
requestMethod: method,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const respText = resp.data;
|
const respText = resp.data;
|
||||||
if (typeof respText !== "string") {
|
if (typeof respText !== "string") {
|
||||||
|
Loading…
Reference in New Issue
Block a user