trycatch characterJoiner handlers

This commit is contained in:
Labhansh Agrawal
2021-11-24 18:27:33 +05:30
parent 20141518d9
commit 070afc64c8
+12 -2
View File
@@ -176,10 +176,20 @@ export class CharacterJoinerService implements ICharacterJoinerService {
// At this point we already know that there is at least one joiner so
// we can just pull its value and assign it directly rather than
// merging it into an empty array, which incurs unnecessary writes.
const joinedRanges: [number, number][] = this._characterJoiners[0].handler(text);
let joinedRanges: [number, number][] = [];
try {
joinedRanges = this._characterJoiners[0].handler(text);
} catch (error) {
console.error(error);
}
for (let i = 1; i < this._characterJoiners.length; i++) {
// We merge any overlapping ranges across the different joiners
const joinerRanges = this._characterJoiners[i].handler(text);
let joinerRanges: [number, number][] = [];
try {
joinerRanges = this._characterJoiners[i].handler(text);
} catch (error) {
console.error(error);
}
for (let j = 0; j < joinerRanges.length; j++) {
CharacterJoinerService._mergeRanges(joinedRanges, joinerRanges[j]);
}