mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-07 12:42:00 +08:00
Improve network error handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
// toErrorString returns a string representaion of axios error.
|
||||
export function toErrorString(error: AxiosError<string>): string {
|
||||
// toErrorStringWithHttpStatus returns a string representaion of axios error with HTTP status.
|
||||
export function toErrorStringWithHttpStatus(error: AxiosError<string>): string {
|
||||
const { response } = error;
|
||||
if (!response) {
|
||||
return "error: no error response data available";
|
||||
@@ -9,6 +9,15 @@ export function toErrorString(error: AxiosError<string>): string {
|
||||
return `${response.status} (${response.statusText}): ${response.data}`;
|
||||
}
|
||||
|
||||
// toErrorString returns a string representaion of axios error.
|
||||
export function toErrorString(error: AxiosError<string>): string {
|
||||
const { response } = error;
|
||||
if (!response) {
|
||||
return "Unknown error occurred. See the logs for details.";
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
hour: number;
|
||||
minute: number;
|
||||
|
Reference in New Issue
Block a user