Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Redirect to 404 Page When Note is Not Found #277

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Tushar504
Copy link

@Tushar504 Tushar504 linked an issue Nov 16, 2024 that may be closed by this pull request
@Tushar504 Tushar504 requested review from neSpecc and e11sy November 16, 2024 12:02
noteTools.value = response.tools;
parentNote.value = response.parentNote;
} catch (error) {
void router.push('/error');
Copy link
Member

@neSpecc neSpecc Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to separate 4xx errors and other errors. If 4xx error happen, show 404 error page. In case of other errors, show 500 "Unexpected error" page

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request you to review new changes

@Tushar504 Tushar504 requested a review from neSpecc November 19, 2024 15:51
src/domain/entities/errors/ApiError.ts Outdated Show resolved Hide resolved
src/application/services/useNote.ts Outdated Show resolved Hide resolved
@Tushar504 Tushar504 requested a review from e11sy November 20, 2024 16:28
Comment on lines 187 to 197
path: '/error',
component: ErrorPage,
meta: {
layout: 'fullpage',
pageTitleI18n: 'pages.notFound',
pageTitleI18n: 'pages.error',
discardTabOnLeave: true,
},
props: {
code: 404,
},
props: route => ({
code: route.query.code,
customMessage: route.query.message,
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

404 page was actually needed (this was a syntax for each unexpected url, that would show 404 page not found)

we need to create separate /error page, that should have statusCode property and show different info by different status code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also better to use route.params for code prop

@Tushar504 Tushar504 requested a review from e11sy November 28, 2024 18:16
Comment on lines +3 to +7
/**
* Domain error thrown when unknown error occurs
*/
export default class ApiError extends DomainError {
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think, that DomainError actually extends ApiError

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, currently it is not needed, I had created the ApiError to consider it as default error, to check api error response is instance of ApiError or not,

parentNote.value = response.parentNote;
} catch (error) {
if (error instanceof NotFoundError) {
void router.push(`/error/404?message=${error.message}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to specify error message directly, instead of using error.message. And use i18n for that.

Other code looks good for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect to 404 Page When Note is Not Found
3 participants