Fix: allow the error from getUser to really be thrown (#437)
We have been catching the error thrown by the getUser fetch, but since our state machine needs to fire onError we should actually *not* wrap it in a try/catch statement. Signed-off-by: Frank Noirot <frank@kittycad.io>
This commit is contained in:
@ -118,16 +118,14 @@ async function getUser(context: UserContext) {
|
|||||||
if (!context.token && '__TAURI__' in window) throw 'not log in'
|
if (!context.token && '__TAURI__' in window) throw 'not log in'
|
||||||
if (context.token) headers['Authorization'] = `Bearer ${context.token}`
|
if (context.token) headers['Authorization'] = `Bearer ${context.token}`
|
||||||
if (SKIP_AUTH) return LOCAL_USER
|
if (SKIP_AUTH) return LOCAL_USER
|
||||||
try {
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
|
|
||||||
const user = await response.json()
|
const user = await response.json()
|
||||||
if ('error_code' in user) throw new Error(user.message)
|
if ('error_code' in user) throw new Error(user.message)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user