luckyframework / avram

A Crystal database wrapper for reading, writing, and migrating Postgres databases.
https://luckyframework.github.io/avram/
MIT License
165 stars 64 forks source link

Allow String keys to be set for error messages #1061

Open jwoertink opened 3 months ago

jwoertink commented 3 months ago

https://github.com/luckyframework/avram/blob/a604962a50f630d58b85c88e1efd5e73fbdb09f8/src/avram/operation_errors.cr#L19

I have a case where I get errors back from an API JSON. I want to pass those along in the error messages, but I can't just add_error(err["key"].as_s, err["val"].as_s), and there's no way to convert JSON to Symbol, or a String to a Symbol.

The big issue here is that it becomes a major breaking change to allow both Symbol and String. I'm not sure what the solution is here, but we should definitely make this more flexible.