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

Improve DB::MappingException usage #129

Merged

Conversation

straight-shoota
Copy link
Member

This adds more locations where DB::MappingException is raised and it adds information about the type and property that failed to deserialize.

cf. crystal-lang/crystal#9274

@@ -3,6 +3,19 @@ module DB
end

class MappingException < Error
getter klass
Copy link
Member

@bcardiff bcardiff Sep 14, 2020

Choose a reason for hiding this comment

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

Is there a reason why you prefer to store the class name instead of the metaclass directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO it's good to keep exception types as simple es possible. Having the metaclass directly doesn't add a real benefit. It's just informational and a string should suffice. This makes it easier to introspect/export an exception instance.

@bcardiff bcardiff merged commit 5a7d27e into crystal-lang:master Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants