Skip to content

Commit

Permalink
handle more error cases for userHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
ong6 committed Nov 2, 2023
1 parent e78450b commit 19bb77d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 7 deletions.
44 changes: 44 additions & 0 deletions bash.exe.stackdump
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Exception: STATUS_STACK_OVERFLOW at rip=0010040B625
rax=0000000000000000 rbx=00000000FFE04040 rcx=0000000000000000
rdx=0000000000000000 rsi=00000001004F73A0 rdi=00000000000000C8
r8 =0000000000000000 r9 =00000000FFFFDE08 r10=00000000FFFFE458
r11=0000000100000000 r12=0000000000000000 r13=0000000800641E70
r14=0000000000000000 r15=00000000FFFFFFFF
rbp=0000000000000000 rsp=00000000FFE03E40
program=C:\Program Files\Git\usr\bin\bash.exe, pid 1795, thread
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
00000000000 0010040B625 (001004036F5, 00000000010, 00000000000, 000FFE04DB0)
00000000010 00100401FFA (00210199B0B, 00800082CE0, 00800642000, 00800641E70)
00000000010 0010046ED5C (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
00800641CB0 00100417AD9 (00210199B0B, 00800082CE0, 008006415A0, 00800641CB0)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
00800641250 00100417AD9 (00210199B0B, 00800082CE0, 00800640B40, 00800641250)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
008006407F0 00100417AD9 (00210199B0B, 00800082CE0, 008006400E0, 008006407F0)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063FD90 00100417AD9 (00210199B0B, 00800082CE0, 0080063F680, 0080063FD90)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063F330 00100417AD9 (00210199B0B, 00800082CE0, 0080063EC20, 0080063F330)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063E8D0 00100417AD9 (00210199B0B, 00800082CE0, 0080063E1C0, 0080063E8D0)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063DE70 00100417AD9 (00210199B0B, 00800082CE0, 0080063D760, 0080063DE70)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063D410 00100417AD9 (00210199B0B, 00800082CE0, 0080063CD00, 0080063D410)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063C9B0 00100417AD9 (00210199B0B, 00800082CE0, 0080063C2A0, 0080063C9B0)
00000000010 0010046F115 (001004FA2EA, 00000000415, 0021032C948, 00000000000)
00000000010 0010044A6AF (0010000001F, 00000000000, 00000000010, 001004FA2EA)
0080063BF50 00100417AD9 (00210199B0B, 00800082CE0, 0080063B840, 0080063BF50)
End of stack trace (more stack frames may be present)
27 changes: 20 additions & 7 deletions frontend/src/pages/api/userHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ export const updateUserByUid = async (user: EditableUser, currentUser: any) => {
headers: {
"Content-Type": "application/json",
"User-Id-Token": idToken,
"User-Id": currentUser.uid
"User-Id": currentUser.uid,
},
body: JSON.stringify(user),
});

const data = await response.json();
if (response.status === 201) {
const data = await response.json();
return data;
} else {
const text = await response.text();
throw new Error(
`Unexpected response (status: ${response.status}): ${text}`
);
}
} catch (error) {
console.error("There was an error updating the user", error);
Expand All @@ -40,18 +45,26 @@ export const getUserByUid = async (uid: string, currentUser: any) => {
headers: {
"Content-Type": "application/json",
"User-Id-Token": idToken,
"User-Id": currentUser.uid
"User-Id": currentUser.uid,
},
});

const data = await response.json();
if (response.status === 200) {
if (
response.ok &&
response.headers.get("Content-Type")?.includes("application/json")
) {
const data = await response.json();
return data;
} else if (response.status === 204) {
return null;
} else {
throw new Error(response.statusText);
const text = await response.text();
throw new Error(
`Unexpected response (status: ${response.status}): ${text}`
);
}
} catch (error) {
console.error("There was an error getting the user", error);
throw error;
}
};
};

0 comments on commit 19bb77d

Please sign in to comment.