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,
|
body: data,
|
||||||
})
|
})
|
||||||
.then((res) => res.text())
|
.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) => {
|
.then((json) => {
|
||||||
if (json.type !== 'success') {
|
if (json.type !== 'success') {
|
||||||
return uploadError(
|
return uploadError(
|
||||||
|
@ -470,7 +476,7 @@ export const doUploadThumbnail = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const userInput = [fileName, fileExt, fileType, thumbnail];
|
const userInput = [fileName, fileExt, fileType, thumbnail];
|
||||||
uploadError(`${message}\nUser input: ${userInput.join(', ')}`);
|
uploadError(`${message}\nUser input: ${userInput.join(' | ')}`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue