mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2025-02-22 08:41:04 -05:00
Added more details to the error message
This commit is contained in:
parent
5bc986e4cc
commit
e07b3d5c99
2 changed files with 10 additions and 2 deletions
|
@ -97,7 +97,11 @@ export async function uploadFile(id: string, data: Record<string, any>, file: Fi
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to upload file: ${response.status} (${response.statusText})`)
|
let errorText = response.statusText;
|
||||||
|
try {
|
||||||
|
errorText += `, ${await response.text()}`;
|
||||||
|
} catch { }
|
||||||
|
throw new Error(`Failed to upload file: ${response.status} (${errorText})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<{ id: number }>await response.json()).id;
|
return (<{ id: number }>await response.json()).id;
|
||||||
|
|
|
@ -23,7 +23,11 @@ export async function createVersion(id: string, data: Record<string, any>, files
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to upload file: ${response.status} (${response.statusText})`)
|
let errorText = response.statusText;
|
||||||
|
try {
|
||||||
|
errorText += `, ${await response.text()}`;
|
||||||
|
} catch { }
|
||||||
|
throw new Error(`Failed to upload file: ${response.status} (${errorText})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<{ id: string }>await response.json()).id;
|
return (<{ id: string }>await response.json()).id;
|
||||||
|
|
Loading…
Add table
Reference in a new issue