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: improve error message on registration failed #242

Merged
merged 6 commits into from
Jun 24, 2020
Merged

fix: improve error message on registration failed #242

merged 6 commits into from
Jun 24, 2020

Conversation

marcosvega91
Copy link
Member

I have changed the error message that will be shown if navigator.serviceWorker.register throw an error.

Now the error shows the complete message text from error object and a tip in the case the user didn't run npx msw init <PUBLIC_DIR> in his project.

An example of message is:

[MSW] Failed to register a ServiceWorker for scope ('http://localhost:62036/') with script ('http://localhost:62036/invalidServiceWorker'): A bad HTTP response code (404) was received when fetching the script. If the worker file has not been found maybe you didn't run "npx msw init <PUBLIC_DIR>"

@marcosvega91
Copy link
Member Author

I need to update the test, my stupid fault ✌️

@marcosvega91
Copy link
Member Author

now is ready, let me know :)

@kettanaito
Copy link
Member

Awesome changes, @marcosvega91! Thank you.

I've updated your feature branch, and slightly modified the error message when the worker is not found. I think it's better if we are definitely sure that the non-existing worker is the issue, and can provide a more targeted error message with instructions. All the other errors are handled using a generic error message printed to browser's console.

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

Thank you once more, @marcosvega91! Welcome to contributors 🎉

@kettanaito kettanaito merged commit 36463bf into mswjs:master Jun 24, 2020
@marcosvega91 marcosvega91 deleted the pr/fix_error_message_onstart branch June 24, 2020 07:05
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.

2 participants