Add hint popup on string length overflow
| @@ -1205,7 +1205,7 @@ export async function getCharacters() { | ||
| 1205 | 1205 | headers: getRequestHeaders(), |
| 1206 | 1206 | body: JSON.stringify({}), |
| 1207 | 1207 | }); |
| 1208 | 1208 | if (response.ok === true) { |
| 1209 | 1209 | const previousAvatar = this_chid !== undefined ? characters[this_chid]?.avatar : null; |
| 1210 | 1210 | characters.splice(0, characters.length); |
| 1211 | 1211 | const getData = await response.json(); |
| @@ -1234,6 +1234,12 @@ export async function getCharacters() { | ||
| 1234 | 1234 | |
| 1235 | 1235 | await getGroups(); |
| 1236 | 1236 | await printCharacters(true); |
| 1237 | + } else { | |
| 1238 | + console.error('Failed to fetch characters:', response.statusText); | |
| 1239 | + const errorData = await response.json(); | |
| 1240 | + if (errorData?.overflow) { | |
| 1241 | + await Popup.show.text(t`Character data length limit reached`, t`To resolve this, set "performance.lazyLoadCharacters" to "true" in config.yaml and restart the server.`); | |
| 1242 | + } | |
| 1237 | 1243 | } |
| 1238 | 1244 | } |
| 1239 | 1245 | |
| @@ -1213,7 +1213,8 @@ router.post('/all', async function (request, response) { | ||
| 1213 | 1213 | return response.send(data); |
| 1214 | 1214 | } catch (err) { |
| 1215 | 1215 | console.error(err); |
| 1216 | - response.sendStatus(500); | |
| 1216 | + const isRangeError = err instanceof RangeError; | |
| 1217 | + response.status(500).send({ overflow: isRangeError, error: true }); | |
| 1217 | 1218 | } |
| 1218 | 1219 | }); |
| 1219 | 1220 | |