Add JSON parse error debug logging in saveWizard
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fc358b53c7
commit
d288b2b71c
1 changed files with 15 additions and 1 deletions
|
|
@ -145,7 +145,21 @@ try {
|
|||
// Clean control characters that Lucee's JSON parser can't handle
|
||||
requestBody = reReplace(requestBody, "[\x00-\x08\x0B\x0C\x0E-\x1F]", "", "all");
|
||||
|
||||
data = deserializeJSON(requestBody);
|
||||
try {
|
||||
data = deserializeJSON(requestBody);
|
||||
} catch (any jsonErr) {
|
||||
// Log snippet around error for debugging
|
||||
nums = reMatch("\d+", jsonErr.message);
|
||||
errorPos = 0;
|
||||
for (n in nums) { if (val(n) > 1000) { errorPos = val(n); break; } }
|
||||
if (errorPos > 0) {
|
||||
snippet = mid(requestBody, max(1, errorPos - 100), 250);
|
||||
arrayAppend(response.errors, "JSON parse failed near position #errorPos#: [#snippet#]");
|
||||
}
|
||||
arrayAppend(response.errors, jsonErr.message);
|
||||
writeOutput(serializeJSON(response));
|
||||
abort;
|
||||
}
|
||||
|
||||
businessId = structKeyExists(data, "businessId") ? val(data.businessId) : 0;
|
||||
userId = structKeyExists(data, "userId") ? val(data.userId) : 0;
|
||||
|
|
|
|||
Reference in a new issue