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

Use SchemaParseError for invalid schemas #5722

Merged
merged 9 commits into from
Apr 19, 2023
Merged

Use SchemaParseError for invalid schemas #5722

merged 9 commits into from
Apr 19, 2023

Conversation

elle-j
Copy link
Contributor

@elle-j elle-j commented Apr 12, 2023

What, How & Why?

Rather than throwing an AssertionError or Error when opening a realm with invalid schemas, a SchemaParseError is introduced to use instead.

This closes #5198.

☑️ ToDos

  • 📝 Changelog entry
  • 🚦 Tests (small update to assert instance of the error)

packages/realm/src/index.ts Outdated Show resolved Hide resolved
@elle-j elle-j marked this pull request as draft April 12, 2023 14:00
Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

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

Sounds like a good change to me. Look great!

@elle-j elle-j marked this pull request as ready for review April 13, 2023 09:04
Copy link
Contributor Author

@elle-j elle-j Apr 13, 2023

Choose a reason for hiding this comment

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

The only change in this file:

  • Wrapped the validatePropertySchema() and validateObjectSchema() bodies in a try-catch to rethrow errors as PropertySchemaParseError and ObjectSchemaParseError respectively, so that this error also applies to invalid JS data types. (This used to throw a mix of Error, TypeError, TypeAssertionError, or AssertionError depending on how assert was called.)

Notes:

  • I'm not wrapping validateRealmSchema() since validateObjectSchema() is also called directly.

CHANGELOG.md Outdated Show resolved Hide resolved
@elle-j elle-j merged commit 714406b into main Apr 19, 2023
@elle-j elle-j deleted the lj/schema-parse-error branch April 19, 2023 19:34
papafe added a commit that referenced this pull request Apr 21, 2023
* main:
  Added note in docs for change listeners (#5749)
  Update CHANGELOG entry (#5751)
  Use `SchemaParseError` for invalid schemas (#5722)
  Improving Electron tests (#5738)
  Support SSL Sync Configuration (#5507)

# Conflicts:
#	CHANGELOG.md
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a SchemaParseError that the new parser should use.
5 participants