Add some more logging (#2402)
* Add a few logs * Report unknown create account errors separately * Downgrade to warn * Nvmzio/stable
parent
d95972c9ff
commit
2f6f27c4fb
|
@ -181,14 +181,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
|
|
||||||
const createAccount = React.useCallback<ApiContext['createAccount']>(
|
const createAccount = React.useCallback<ApiContext['createAccount']>(
|
||||||
async ({service, email, password, handle, inviteCode}: any) => {
|
async ({service, email, password, handle, inviteCode}: any) => {
|
||||||
logger.debug(
|
logger.info(`session: creating account`, {
|
||||||
`session: creating account`,
|
|
||||||
{
|
|
||||||
service,
|
service,
|
||||||
handle,
|
handle,
|
||||||
},
|
})
|
||||||
logger.DebugContext.session,
|
|
||||||
)
|
|
||||||
track('Try Create Account')
|
track('Try Create Account')
|
||||||
|
|
||||||
const agent = new BskyAgent({service})
|
const agent = new BskyAgent({service})
|
||||||
|
|
|
@ -136,7 +136,13 @@ export async function submit({
|
||||||
msg`Invite code not accepted. Check that you input it correctly and try again.`,
|
msg`Invite code not accepted. Check that you input it correctly and try again.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.error('Failed to create account', {error: e})
|
|
||||||
|
if ([400, 429].includes(e.status)) {
|
||||||
|
logger.warn('Failed to create account', {error: e})
|
||||||
|
} else {
|
||||||
|
logger.error(`Failed to create account (${e.status} status)`, {error: e})
|
||||||
|
}
|
||||||
|
|
||||||
uiDispatch({type: 'set-processing', value: false})
|
uiDispatch({type: 'set-processing', value: false})
|
||||||
uiDispatch({type: 'set-error', value: cleanError(errMsg)})
|
uiDispatch({type: 'set-error', value: cleanError(errMsg)})
|
||||||
throw e
|
throw e
|
||||||
|
|
|
@ -107,17 +107,21 @@ export const LoginForm = ({
|
||||||
})
|
})
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
const errMsg = e.toString()
|
const errMsg = e.toString()
|
||||||
logger.warn('Failed to login', {error: e})
|
|
||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
if (errMsg.includes('Authentication Required')) {
|
if (errMsg.includes('Authentication Required')) {
|
||||||
|
logger.info('Failed to login due to invalid credentials', {
|
||||||
|
error: errMsg,
|
||||||
|
})
|
||||||
setError(_(msg`Invalid username or password`))
|
setError(_(msg`Invalid username or password`))
|
||||||
} else if (isNetworkError(e)) {
|
} else if (isNetworkError(e)) {
|
||||||
|
logger.warn('Failed to login due to network error', {error: errMsg})
|
||||||
setError(
|
setError(
|
||||||
_(
|
_(
|
||||||
msg`Unable to contact your service. Please check your Internet connection.`,
|
msg`Unable to contact your service. Please check your Internet connection.`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
logger.warn('Failed to login', {error: errMsg})
|
||||||
setError(cleanError(errMsg))
|
setError(cleanError(errMsg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue