Fix freeze when output text decoding fails (#1573)
This commit is contained in:
parent
cc2c6d20fd
commit
042afe4157
@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Dish from "../../core/Dish.mjs";
|
import Dish from "../../core/Dish.mjs";
|
||||||
|
import DishError from "../../core/errors/DishError.mjs";
|
||||||
|
import { CHR_ENC_SIMPLE_REVERSE_LOOKUP } from "../../core/lib/ChrEnc.mjs";
|
||||||
import Utils from "../../core/Utils.mjs";
|
import Utils from "../../core/Utils.mjs";
|
||||||
import cptable from "codepage";
|
import cptable from "codepage";
|
||||||
import loglevelMessagePrefix from "loglevel-message-prefix";
|
import loglevelMessagePrefix from "loglevel-message-prefix";
|
||||||
@ -98,7 +100,7 @@ async function bufferToStr(data) {
|
|||||||
try {
|
try {
|
||||||
str = cptable.utils.decode(data.encoding, new Uint8Array(data.buffer));
|
str = cptable.utils.decode(data.encoding, new Uint8Array(data.buffer));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
str = err;
|
str = new DishError(`Error decoding buffer with encoding ${CHR_ENC_SIMPLE_REVERSE_LOOKUP[data.encoding]}: ${err.message}`).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user