You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
634 B
24 lines
634 B
import { AxiosError } from "axios";
|
|
|
|
export const handleApiError = (error: AxiosError, endpoint: string) => {
|
|
if (process.env.VITE_PLATFORM === "capacitor") {
|
|
console.error(`[Capacitor API Error] ${endpoint}:`, {
|
|
message: error.message,
|
|
status: error.response?.status,
|
|
data: error.response?.data,
|
|
config: {
|
|
url: error.config?.url,
|
|
method: error.config?.method,
|
|
headers: error.config?.headers,
|
|
},
|
|
});
|
|
}
|
|
|
|
// Specific handling for rate limits
|
|
if (error.response?.status === 400) {
|
|
console.warn(`[Rate Limit] ${endpoint}`);
|
|
return null;
|
|
}
|
|
|
|
throw error;
|
|
};
|
|
|