mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 01:41:05 -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) {
|
||||
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;
|
||||
|
|
|
@ -23,7 +23,11 @@ export async function createVersion(id: string, data: Record<string, any>, files
|
|||
});
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue