mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-20 08:56:29 +00:00
* feat: support multi ingestion keys * fix: remove unwanted changes * feat: limits ui * feat: handle limit updates from component * feat: handle limit updates per signal * feat: integrate multiple ingestion key api * feat: handle crud for limits * fix: lint errors * feat: support query search for ingestion name * feat: show utilized size in limits * feat: show multiple ingestions ui only if gateway is enabled * feat: handle decimal values for ingestion size * feat: enable multiple ingestion keys for all users with gateway enabled * chore: remove yarn.lock --------- Co-authored-by: Yunus A M <younix@Yunuss-MacBook-Pro.local> Co-authored-by: Prashant Shahi <prashant@signoz.io>
65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { AxiosError, AxiosResponse } from 'axios';
|
|
import { ErrorResponse } from 'types/api';
|
|
import { ErrorStatusCode } from 'types/common';
|
|
|
|
export function ErrorResponseHandler(error: AxiosError): ErrorResponse {
|
|
const { response, request } = error;
|
|
if (response) {
|
|
// client received an error response (5xx, 4xx)
|
|
// making the error status code as standard Error Status Code
|
|
const statusCode = response.status as ErrorStatusCode;
|
|
|
|
if (statusCode >= 400 && statusCode < 500) {
|
|
const { data } = response as AxiosResponse;
|
|
|
|
if (statusCode === 404) {
|
|
return {
|
|
statusCode,
|
|
payload: null,
|
|
error: data.errorType || data.type,
|
|
message: null,
|
|
};
|
|
}
|
|
|
|
const { errors, error } = data;
|
|
|
|
const errorMessage =
|
|
Array.isArray(errors) && errors.length >= 1 ? errors[0].msg : error;
|
|
|
|
return {
|
|
statusCode,
|
|
payload: null,
|
|
error: errorMessage,
|
|
message: (response.data as any)?.status,
|
|
body: JSON.stringify((response.data as any).data),
|
|
};
|
|
}
|
|
|
|
return {
|
|
statusCode,
|
|
payload: null,
|
|
error: 'Something went wrong',
|
|
message: null,
|
|
};
|
|
}
|
|
if (request) {
|
|
// client never received a response, or request never left
|
|
console.error('client never received a response, or request never left');
|
|
|
|
return {
|
|
statusCode: 500,
|
|
payload: null,
|
|
error: 'Something went wrong',
|
|
message: null,
|
|
};
|
|
}
|
|
// anything else
|
|
console.error('any');
|
|
return {
|
|
statusCode: 500,
|
|
payload: null,
|
|
error: String(error),
|
|
message: null,
|
|
};
|
|
}
|