Thumbnail uploads: handle non-JSON responses
This commit is contained in:
parent
01459d906a
commit
57f48f462e
1 changed files with 8 additions and 2 deletions
|
@ -441,7 +441,13 @@ export const doUploadThumbnail = (
|
|||
body: data,
|
||||
})
|
||||
.then((res) => res.text())
|
||||
.then((text) => (text.length ? JSON.parse(text) : {}))
|
||||
.then((text) => {
|
||||
try {
|
||||
return text.length ? JSON.parse(text) : {};
|
||||
} catch {
|
||||
throw new Error(text);
|
||||
}
|
||||
})
|
||||
.then((json) => {
|
||||
if (json.type !== 'success') {
|
||||
return uploadError(
|
||||
|
@ -470,7 +476,7 @@ export const doUploadThumbnail = (
|
|||
}
|
||||
|
||||
const userInput = [fileName, fileExt, fileType, thumbnail];
|
||||
uploadError(`${message}\nUser input: ${userInput.join(', ')}`);
|
||||
uploadError(`${message}\nUser input: ${userInput.join(' | ')}`);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue