share funxtions
This commit is contained in:
@@ -16,6 +16,7 @@ export async function api(path, options = {}) {
|
||||
if (!response.ok) {
|
||||
const defaults = { 400: "Invalid request.", 401: "Authentication required.", 403: "Access denied.", 404: "The requested resource was not found.", 405: "This operation is not allowed.", 409: "The requested change conflicts with existing data.", 413: "The uploaded data is too large.", 429: "Too many requests. Try again later.", 500: "Server error. Try again later.", 503: "Service temporarily unavailable." };
|
||||
const requestError = new Error(data.error || defaults[response.status] || `Request failed (${response.status}).`);
|
||||
requestError.status = response.status;
|
||||
logWarn("api.failed", { method: options.method || "GET", path, status: response.status, message: requestError.message });
|
||||
throw requestError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user