Fix other error logs while I'm at it

zio/stable
Eric Bailey 2023-11-04 12:58:50 -05:00
parent df0dcf32f9
commit 7e29ebbadb
40 changed files with 104 additions and 86 deletions

View File

@ -22,7 +22,7 @@ export function useFollowProfile(profile: AppBskyActorDefs.ProfileViewBasic) {
following: false,
}
} catch (e: any) {
store.log.error('Failed to delete follow', e)
store.log.error('Failed to delete follow', {error: e})
throw e
}
} else if (state === FollowState.NotFollowing) {
@ -40,7 +40,7 @@ export function useFollowProfile(profile: AppBskyActorDefs.ProfileViewBasic) {
following: true,
}
} catch (e: any) {
store.log.error('Failed to create follow', e)
store.log.error('Failed to create follow', {error: e})
throw e
}
}

View File

@ -25,7 +25,7 @@ export async function setupState(serviceUri = DEFAULT_SERVICE) {
rootStore.log.debug('Initial hydrate', {hasSession: !!data.session})
rootStore.hydrate(data)
} catch (e: any) {
rootStore.log.error('Failed to load state from storage', e)
rootStore.log.error('Failed to load state from storage', {error: e})
}
rootStore.attemptSessionResumption()

View File

@ -163,7 +163,7 @@ export class PostThreadModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch post thread', err)
this.rootStore.log.error('Failed to fetch post thread', {error: err})
}
this.notFound = err instanceof GetPostThread.NotFoundError
}

View File

@ -235,7 +235,7 @@ export class ProfileModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch profile', err)
this.rootStore.log.error('Failed to fetch profile', {error: err})
}
}

View File

@ -120,7 +120,7 @@ export class FeedsDiscoveryModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch popular feeds', err)
this.rootStore.log.error('Failed to fetch popular feeds', {error: err})
}
}

View File

@ -144,7 +144,7 @@ export class SuggestedActorsModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch suggested actors', err)
this.rootStore.log.error('Failed to fetch suggested actors', {error: err})
}
}
}

View File

@ -401,7 +401,9 @@ export class NotificationsFeedModel {
this._setQueued(this._filterNotifications(queueModels))
this._countUnread()
} catch (e) {
this.rootStore.log.error('NotificationsModel:syncQueue failed', {e})
this.rootStore.log.error('NotificationsModel:syncQueue failed', {
error: e,
})
} finally {
this.lock.release()
}
@ -481,7 +483,9 @@ export class NotificationsFeedModel {
this.lastSync ? this.lastSync.toISOString() : undefined,
)
} catch (e: any) {
this.rootStore.log.warn('Failed to update notifications read state', e)
this.rootStore.log.warn('Failed to update notifications read state', {
error: e,
})
}
}
@ -501,13 +505,12 @@ export class NotificationsFeedModel {
this.error = cleanError(error)
this.loadMoreError = cleanError(loadMoreError)
if (error) {
this.rootStore.log.error('Failed to fetch notifications', error)
this.rootStore.log.error('Failed to fetch notifications', {error})
}
if (loadMoreError) {
this.rootStore.log.error(
'Failed to load more notifications',
loadMoreError,
)
this.rootStore.log.error('Failed to load more notifications', {
error: loadMoreError,
})
}
}

View File

@ -51,7 +51,7 @@ export class PostsFeedItemModel {
this.richText = undefined
rootStore.log.warn(
'app.bsky.feed.getTimeline or app.bsky.feed.getAuthorFeed served an unexpected record type',
this.post.record,
{record: this.post.record},
)
}
this.reply = v.reply

View File

@ -324,13 +324,12 @@ export class PostsFeedModel {
this.knownError = detectKnownError(this.feedType, error)
this.loadMoreError = cleanError(loadMoreError)
if (error) {
this.rootStore.log.error('Posts feed request failed', error)
this.rootStore.log.error('Posts feed request failed', {error})
}
if (loadMoreError) {
this.rootStore.log.error(
'Posts feed load-more request failed',
loadMoreError,
)
this.rootStore.log.error('Posts feed load-more request failed', {
error: loadMoreError,
})
}
}

View File

@ -98,7 +98,7 @@ export class ActorFeedsModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch user followers', err)
this.rootStore.log.error('Failed to fetch user followers', {error: err})
}
}

View File

@ -86,7 +86,7 @@ export class BlockedAccountsModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch user followers', err)
this.rootStore.log.error('Failed to fetch user followers', {error: err})
}
}

View File

@ -97,7 +97,7 @@ export class LikesModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch likes', err)
this.rootStore.log.error('Failed to fetch likes', {error: err})
}
}

View File

@ -204,10 +204,12 @@ export class ListsListModel {
this.error = cleanError(err)
this.loadMoreError = cleanError(loadMoreErr)
if (err) {
this.rootStore.log.error('Failed to fetch user lists', err)
this.rootStore.log.error('Failed to fetch user lists', {error: err})
}
if (loadMoreErr) {
this.rootStore.log.error('Failed to fetch user lists', loadMoreErr)
this.rootStore.log.error('Failed to fetch user lists', {
error: loadMoreErr,
})
}
}

View File

@ -86,7 +86,7 @@ export class MutedAccountsModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch user followers', err)
this.rootStore.log.error('Failed to fetch user followers', {error: err})
}
}

View File

@ -100,7 +100,7 @@ export class RepostedByModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch reposted by view', err)
this.rootStore.log.error('Failed to fetch reposted by view', {error: err})
}
}

View File

@ -99,7 +99,7 @@ export class UserFollowersModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch user followers', err)
this.rootStore.log.error('Failed to fetch user followers', {error: err})
}
}

View File

@ -130,7 +130,7 @@ export class RootStoreModel {
})
this.updateSessionState()
} catch (e: any) {
this.log.warn('Failed to initialize session', e)
this.log.warn('Failed to initialize session', {error: e})
}
}
@ -184,7 +184,7 @@ export class RootStoreModel {
await this.me.updateIfNeeded()
await this.preferences.sync()
} catch (e: any) {
this.log.error('Failed to fetch latest state', e)
this.log.error('Failed to fetch latest state', {error: e})
}
}

View File

@ -78,7 +78,7 @@ export class CreateAccountModel {
} catch (err: any) {
this.rootStore.log.warn(
`Failed to fetch service description for ${this.serviceUrl}`,
err,
{error: err},
)
this.setError(
'Unable to contact your service. Please check your Internet connection.',
@ -127,7 +127,7 @@ export class CreateAccountModel {
errMsg =
'Invite code not accepted. Check that you input it correctly and try again.'
}
this.rootStore.log.error('Failed to create account', e)
this.rootStore.log.error('Failed to create account', {error: e})
this.setIsProcessing(false)
this.setError(cleanError(errMsg))
throw e

View File

@ -223,10 +223,14 @@ export class ProfileUiModel {
await Promise.all([
this.profile
.setup()
.catch(err => this.rootStore.log.error('Failed to fetch profile', err)),
.catch(err =>
this.rootStore.log.error('Failed to fetch profile', {error: err}),
),
this.feed
.setup()
.catch(err => this.rootStore.log.error('Failed to fetch feed', err)),
.catch(err =>
this.rootStore.log.error('Failed to fetch feed', {error: err}),
),
])
runInAction(() => {
this.isAuthenticatedUser =
@ -237,7 +241,9 @@ export class ProfileUiModel {
this.lists.source = this.profile.did
this.lists
.loadMore()
.catch(err => this.rootStore.log.error('Failed to fetch lists', err))
.catch(err =>
this.rootStore.log.error('Failed to fetch lists', {error: err}),
)
}
async refresh() {

View File

@ -126,7 +126,7 @@ export class SavedFeedsModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch user feeds', err)
this.rootStore.log.error('Failed to fetch user feeds', {err})
}
}

View File

@ -83,7 +83,7 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => {
}
store.log.warn(
`Failed to fetch service description for ${serviceUrl}`,
err,
{error: err},
)
setError(
'Unable to contact your service. Please check your Internet connection.',
@ -349,7 +349,7 @@ const LoginForm = ({
})
} catch (e: any) {
const errMsg = e.toString()
store.log.warn('Failed to login', e)
store.log.warn('Failed to login', {error: e})
setIsProcessing(false)
if (errMsg.includes('Authentication Required')) {
setError('Invalid username or password')
@ -578,7 +578,7 @@ const ForgotPasswordForm = ({
onEmailSent()
} catch (e: any) {
const errMsg = e.toString()
store.log.warn('Failed to request password reset', e)
store.log.warn('Failed to request password reset', {error: e})
setIsProcessing(false)
if (isNetworkError(e)) {
setError(
@ -734,7 +734,7 @@ const SetNewPasswordForm = ({
onPasswordSet()
} catch (e: any) {
const errMsg = e.toString()
store.log.warn('Failed to set new password', e)
store.log.warn('Failed to set new password', {error: e})
setIsProcessing(false)
if (isNetworkError(e)) {
setError(

View File

@ -39,7 +39,7 @@ export function OpenCameraBtn({gallery}: Props) {
gallery.add(img)
} catch (err: any) {
// ignore
store.log.warn('Error using camera', err)
store.log.warn('Error using camera', {error: err})
}
}, [gallery, track, store, requestCameraAccessIfNeeded])

View File

@ -46,7 +46,9 @@ export function useExternalLinkFetch({
setExtLink(undefined)
},
err => {
store.log.error('Failed to fetch post for quote embedding', {err})
store.log.error('Failed to fetch post for quote embedding', {
error: err,
})
setExtLink(undefined)
},
)
@ -64,7 +66,7 @@ export function useExternalLinkFetch({
})
},
err => {
store.log.error('Failed to fetch feed for embedding', {err})
store.log.error('Failed to fetch feed for embedding', {error: err})
setExtLink(undefined)
},
)
@ -82,7 +84,7 @@ export function useExternalLinkFetch({
})
},
err => {
store.log.error('Failed to fetch list for embedding', {err})
store.log.error('Failed to fetch list for embedding', {error: err})
setExtLink(undefined)
},
)

View File

@ -45,7 +45,7 @@ export const FeedSourceCard = observer(function FeedSourceCardImpl({
Toast.show('Removed from my feeds')
} catch (e) {
Toast.show('There was an issue contacting your server')
store.log.error('Failed to unsave feed', {e})
store.log.error('Failed to unsave feed', {error: e})
}
},
})
@ -55,7 +55,7 @@ export const FeedSourceCard = observer(function FeedSourceCardImpl({
Toast.show('Added to my feeds')
} catch (e) {
Toast.show('There was an issue contacting your server')
store.log.error('Failed to save feed', {e})
store.log.error('Failed to save feed', {error: e})
}
}
}, [store, item])

View File

@ -95,7 +95,7 @@ export function Component({}: {}) {
}
} catch (e) {
Toast.show('Failed to create app password.')
store.log.error('Failed to create app password', {e})
store.log.error('Failed to create app password', {error: e})
}
}

View File

@ -69,7 +69,7 @@ export function Component({onChanged}: {onChanged: () => void}) {
`Failed to fetch service description for ${String(
store.agent.service,
)}`,
err,
{error: err},
)
setError(
'Unable to contact your service. Please check your Internet connection.',
@ -113,7 +113,7 @@ export function Component({onChanged}: {onChanged: () => void}) {
onChanged()
} catch (err: any) {
setError(cleanError(err))
store.log.error('Failed to update handle', {handle, err})
store.log.error('Failed to update handle', {handle, error: err})
} finally {
setProcessing(false)
}
@ -343,7 +343,7 @@ function CustomHandleForm({
}
} catch (err: any) {
setError(cleanError(err))
store.log.error('Failed to verify domain', {handle, err})
store.log.error('Failed to verify domain', {handle, error: err})
} finally {
setIsVerifying(false)
}

View File

@ -103,7 +103,7 @@ const AdultContentEnabledPref = observer(
Toast.show(
'There was an issue syncing your preferences with the server',
)
store.log.error('Failed to update preferences with server', {e})
store.log.error('Failed to update preferences with server', {error: e})
}
}
@ -168,7 +168,7 @@ const ContentLabelPref = observer(function ContentLabelPrefImpl({
Toast.show(
'There was an issue syncing your preferences with the server',
)
store.log.error('Failed to update preferences with server', {e})
store.log.error('Failed to update preferences with server', {error: e})
}
},
[store, group],

View File

@ -62,7 +62,7 @@ export const Component = observer(function UserAddRemoveListsImpl({
setMembershipsLoaded(true)
},
err => {
store.log.error('Failed to fetch memberships', {err})
store.log.error('Failed to fetch memberships', {error: err})
},
)
}, [memberships, listsList, store, setSelected, setMembershipsLoaded])
@ -76,7 +76,7 @@ export const Component = observer(function UserAddRemoveListsImpl({
try {
changes = await memberships.updateTo(selected)
} catch (err) {
store.log.error('Failed to update memberships', {err})
store.log.error('Failed to update memberships', {error: err})
return
}
Toast.show('Lists updated')

View File

@ -18,7 +18,9 @@ export const PostLikedBy = observer(function PostLikedByImpl({
const view = React.useMemo(() => new LikesModel(store, {uri}), [store, uri])
useEffect(() => {
view.loadMore().catch(err => store.log.error('Failed to fetch likes', err))
view
.loadMore()
.catch(err => store.log.error('Failed to fetch likes', {error: err}))
}, [view, store.log])
const onRefresh = () => {
@ -27,7 +29,9 @@ export const PostLikedBy = observer(function PostLikedByImpl({
const onEndReached = () => {
view
.loadMore()
.catch(err => view?.rootStore.log.error('Failed to load more likes', err))
.catch(err =>
view?.rootStore.log.error('Failed to load more likes', {error: err}),
)
}
if (!view.hasLoaded) {

View File

@ -23,7 +23,7 @@ export const PostRepostedBy = observer(function PostRepostedByImpl({
useEffect(() => {
view
.loadMore()
.catch(err => store.log.error('Failed to fetch reposts', err))
.catch(err => store.log.error('Failed to fetch reposts', {error: err}))
}, [view, store.log])
const onRefresh = () => {
@ -33,7 +33,7 @@ export const PostRepostedBy = observer(function PostRepostedByImpl({
view
.loadMore()
.catch(err =>
view?.rootStore.log.error('Failed to load more reposts', err),
view?.rootStore.log.error('Failed to load more reposts', {error: err}),
)
}

View File

@ -73,7 +73,7 @@ function FeedgenErrorMessage({
Toast.show(
'There was an an issue removing this feed. Please check your internet connection and try again.',
)
store.log.error('Failed to remove feed', {err})
store.log.error('Failed to remove feed', {error: err})
}
},
onPressCancel() {

View File

@ -26,17 +26,19 @@ export const ProfileFollowers = observer(function ProfileFollowers({
useEffect(() => {
view
.loadMore()
.catch(err => store.log.error('Failed to fetch user followers', err))
.catch(err =>
store.log.error('Failed to fetch user followers', {error: err}),
)
}, [view, store.log])
const onRefresh = () => {
view.refresh()
}
const onEndReached = () => {
view
.loadMore()
.catch(err =>
view?.rootStore.log.error('Failed to load more followers', err),
view.loadMore().catch(err =>
view?.rootStore.log.error('Failed to load more followers', {
error: err,
}),
)
}

View File

@ -150,7 +150,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
: 'ProfileHeader:UnfollowButtonClicked',
)
},
err => store.log.error('Failed to toggle follow', err),
err => store.log.error('Failed to toggle follow', {error: err}),
)
}, [track, view, store.log, setShowSuggestedFollows])
@ -193,7 +193,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
await view.muteAccount()
Toast.show('Account muted')
} catch (e: any) {
store.log.error('Failed to mute account', e)
store.log.error('Failed to mute account', {error: e})
Toast.show(`There was an issue! ${e.toString()}`)
}
}, [track, view, store])
@ -204,7 +204,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
await view.unmuteAccount()
Toast.show('Account unmuted')
} catch (e: any) {
store.log.error('Failed to unmute account', e)
store.log.error('Failed to unmute account', {error: e})
Toast.show(`There was an issue! ${e.toString()}`)
}
}, [track, view, store])
@ -222,7 +222,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
onRefreshAll()
Toast.show('Account blocked')
} catch (e: any) {
store.log.error('Failed to block account', e)
store.log.error('Failed to block account', {error: e})
Toast.show(`There was an issue! ${e.toString()}`)
}
},
@ -242,7 +242,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
onRefreshAll()
Toast.show('Account unblocked')
} catch (e: any) {
store.log.error('Failed to unblock account', e)
store.log.error('Failed to unblock account', {error: e})
Toast.show(`There was an issue! ${e.toString()}`)
}
},

View File

@ -52,7 +52,7 @@ export const ModerationBlockedAccounts = withAuthRequired(
blockedAccounts
.loadMore()
.catch(err =>
store.log.error('Failed to load more blocked accounts', err),
store.log.error('Failed to load more blocked accounts', {error: err}),
)
}, [blockedAccounts, store])

View File

@ -49,7 +49,7 @@ export const ModerationMutedAccounts = withAuthRequired(
mutedAccounts
.loadMore()
.catch(err =>
store.log.error('Failed to load more muted accounts', err),
store.log.error('Failed to load more muted accounts', {error: err}),
)
}, [mutedAccounts, store])

View File

@ -108,14 +108,14 @@ export const ProfileScreen = withAuthRequired(
uiState
.refresh()
.catch((err: any) =>
store.log.error('Failed to refresh user profile', err),
store.log.error('Failed to refresh user profile', {error: err}),
)
}, [uiState, store])
const onEndReached = React.useCallback(() => {
uiState
.loadMore()
.catch((err: any) =>
store.log.error('Failed to load more entries in user profile', err),
uiState.loadMore().catch((err: any) =>
store.log.error('Failed to load more entries in user profile', {
error: err,
}),
)
}, [uiState, store])
const onPressTryAgain = React.useCallback(() => {

View File

@ -165,7 +165,7 @@ export const ProfileFeedScreenInner = observer(
Toast.show(
'There was an an issue updating your feeds, please check your internet connection and try again.',
)
store.log.error('Failed up update feeds', {err})
store.log.error('Failed up update feeds', {error: err})
}
}, [store, feedInfo])
@ -181,7 +181,7 @@ export const ProfileFeedScreenInner = observer(
Toast.show(
'There was an an issue contacting the server, please check your internet connection and try again.',
)
store.log.error('Failed up toggle like', {err})
store.log.error('Failed up toggle like', {error: err})
}
}, [store, feedInfo])
@ -190,7 +190,7 @@ export const ProfileFeedScreenInner = observer(
if (feedInfo) {
feedInfo.togglePin().catch(e => {
Toast.show('There was an issue contacting the server')
store.log.error('Failed to toggle pinned feed', {e})
store.log.error('Failed to toggle pinned feed', {error: e})
})
}
}, [store, feedInfo])

View File

@ -272,7 +272,7 @@ const Header = observer(function HeaderImpl({
Haptics.default()
list.togglePin().catch(e => {
Toast.show('There was an issue contacting the server')
store.log.error('Failed to toggle pinned list', {e})
store.log.error('Failed to toggle pinned list', {error: e})
})
}, [store, list])

View File

@ -166,14 +166,14 @@ const ListItem = observer(function ListItemImpl({
Haptics.default()
item.togglePin().catch(e => {
Toast.show('There was an issue contacting the server')
store.log.error('Failed to toggle pinned feed', {e})
store.log.error('Failed to toggle pinned feed', {error: e})
})
}, [item, store])
const onPressUp = useCallback(
() =>
savedFeeds.movePinnedFeed(item, 'up').catch(e => {
Toast.show('There was an issue contacting the server')
store.log.error('Failed to set pinned feed order', {e})
store.log.error('Failed to set pinned feed order', {error: e})
}),
[store, savedFeeds, item],
)
@ -181,7 +181,7 @@ const ListItem = observer(function ListItemImpl({
() =>
savedFeeds.movePinnedFeed(item, 'down').catch(e => {
Toast.show('There was an issue contacting the server')
store.log.error('Failed to set pinned feed order', {e})
store.log.error('Failed to set pinned feed order', {error: e})
}),
[store, savedFeeds, item],
)

View File

@ -112,7 +112,7 @@ export const SettingsScreen = withAuthRequired(
err => {
store.log.error(
'Failed to reload from server after handle update',
{err},
{error: err},
)
setIsSwitching(false)
},