Skip to content

Commit

Permalink
Try to parse with json parse and provide better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
closertotheend committed Oct 16, 2023
1 parent d75327b commit c97b82c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/helpers/get-user-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ export function getUserData (

const user = checkOneUser(users);

if (typeof user.verifyChanges === "string" && user.verifyChanges[0] === "{") {
user.verifyChanges = JSON.parse(user.verifyChanges);
if (typeof user.verifyChanges === "string") {
try {
user.verifyChanges = JSON.parse(user.verifyChanges);
} catch (e) {
throw new Error(
"Cannot parse user.verifyChanges string field. Incorrect JSON string provided: " + user.verifyChanges
);
}
}

checkUserChecks(user, checks);
Expand Down

0 comments on commit c97b82c

Please sign in to comment.