Skip to content

Commit 3fcb13e

Browse files
leestottCopilot
andauthored
Update 7-bank-project/solution/app.js
Co-authored-by: Copilot <[email protected]>
1 parent 85cc30f commit 3fcb13e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

7-bank-project/solution/app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ async function getAccount(user) {
7272
async function createAccount(accountJson) {
7373
return new Promise(resolve => {
7474
setTimeout(() => {
75-
const data = JSON.parse(accountJson);
75+
let data;
76+
try {
77+
data = JSON.parse(accountJson);
78+
} catch (e) {
79+
return resolve({ error: 'Malformed account data' });
80+
}
7681
if (!data.user) return resolve({ error: 'Username required' });
7782
if (findAccount(data.user)) return resolve({ error: 'User already exists' });
7883
// Set up initial account structure

0 commit comments

Comments
 (0)