More clear message for character import failure

This commit is contained in:
Cohee 2023-08-01 18:13:50 +03:00
parent 7f86551ab4
commit 72974d8a54
2 changed files with 10 additions and 0 deletions

View File

@ -6838,6 +6838,11 @@ function importCharacter(file) {
contentType: false,
processData: false,
success: async function (data) {
if (data.error) {
toastr.error('The file is likely invalid or corrupted.', 'Could not import character');
return;
}
if (data.file_name !== undefined) {
$('#character_search_bar').val('').trigger('input');
$("#rm_info_block").transition({ opacity: 0, duration: 0 });

View File

@ -61,6 +61,11 @@ const parse = async (cardUrl, format) => {
return PNGtext.decode(chunk.data);
});
if (textChunks.length === 0) {
console.error('PNG metadata does not contain any character data.');
throw new Error('No PNG metadata.');
}
return Buffer.from(textChunks[0].text, 'base64').toString('utf8');
default:
break;