Skip to content

refactor: Normalize CORS errors #24

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

Merged
merged 1 commit into from
Jan 29, 2025
Merged

refactor: Normalize CORS errors #24

merged 1 commit into from
Jan 29, 2025

Conversation

nzakas
Copy link
Contributor

@nzakas nzakas commented Jan 29, 2025

This pull request introduces a new CorsError class to handle CORS-related errors more effectively and updates various parts of the codebase to use this new error class. The most important changes involve refactoring existing error handling to use CorsError and updating tests accordingly. This ensures that CORS errors all follow the same uniform messaging.

Introduction of CorsError class:

  • src/cors.js: Added the CorsError class to represent errors that occur when a CORS request is blocked.

Refactoring error handling to use CorsError:

  • src/cors.js: Updated the assertCorsResponse function and methods in the CorsPreflightData class to throw CorsError instead of Error. [1] [2] [3] [4]

Updates to dependent modules:

  • src/fetch-mocker.js: Imported CorsError and updated the FetchMocker class to use the new error class in preflight validation and error handling. [1] [2] [3]

Updates to tests:

@nzakas nzakas merged commit 2e08e65 into main Jan 29, 2025
18 checks passed
@nzakas nzakas deleted the cors-errors branch January 29, 2025 00:27
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.

1 participant