Skip to content

Commit

Permalink
chore: improve profile error reporting (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp authored Aug 14, 2023
1 parent 5156e16 commit 808c970
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/back/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ async function getProfile(req: Request) {
const address = req.params.address
validateAddress(address)

try {
const user = await UserModel.findOne<UserAttributes>({ address: address.toLowerCase() })
const user = await UserModel.findOne<UserAttributes>({ address: address.toLowerCase() })

if (!user) {
throw new RequestError('User not found', RequestError.NotFound)
}
if (!user) {
throw new RequestError('User not found', RequestError.NotFound)
}

try {
const { forum_id } = user

return {
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/useProfile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useQuery } from '@tanstack/react-query'
import isEthereumAddress from 'validator/lib/isEthereumAddress'

import { ErrorClient } from '../clients/ErrorClient'
import { createDefaultAvatar, getProfile } from '../utils/Catalyst'
import { ErrorCategory } from '../utils/errorCategories'

import { DEFAULT_QUERY_STALE_TIME } from './constants'

Expand All @@ -15,7 +13,6 @@ export default function useProfile(address?: string | null) {
const profile = await getProfile(address)
return { profile: profile || createDefaultAvatar(address), isDefaultProfile: !profile }
} catch (error) {
ErrorClient.report('Error getting profile', { error, address, category: ErrorCategory.Profile })
return null
}
}
Expand Down

0 comments on commit 808c970

Please sign in to comment.