Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Fix error report for search result item requests #647

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

myl7
Copy link
Collaborator

@myl7 myl7 commented May 17, 2022

According to

} catch (err: any) {
throw { status: err.response.status, message: err.response.data }
}

When an error occurs from item API, as for the error reporting code

const { data, error }: SWRResponse<OdDriveItem, string> = useSWR(`/api/item/?id=${result.id}`, fetcher)

here error is not a string but { status: number; message: any }

Since the error object is passed into the sub component like

return <SearchResultItemTemplate driveItem={result} driveItemPath={''} itemDescription={error} disabled={true} />

And the itemDescription prop is directly used in {} like

>
{itemDescription}
</div>

which is disallowed for an object other than a string, a React children-related error will be raised if the item API returns an error, which is fixed in the PR.

@vercel
Copy link

vercel bot commented May 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
onedrive-vercel-index ✅ Ready (Inspect) Visit Preview May 17, 2022 at 8:23PM (UTC)

myl7 added a commit to myl7/onedrive-vercel-index that referenced this pull request May 18, 2022
@myl7 myl7 merged commit 07f0314 into spencerwooo:main Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant