simonw/sqlite-transform

Better error handling for lambda

Closed this issue · 4 comments

Errors in code executed using lambda are hard to understand at the moment.

I had a function which returned a list (instead of a string) and it got very difficult to figure out what was going on.

So maybe one thing we can do is have the transform function detect if the return value isn't a supported one (presumably anything other than a string, float or integer) and raise a human-readable error if that happens.

The whole operation is wrapped in a transaction which I think means it will be rolled back automatically if any value fails to transform. Need to verify that this actually happens in a test though.

Also: maybe we should have a --ignore-errors option which ignores individual column value errors (leaving those columns with their own value) rather than reverting the entire operation?

I did sneak this line in but I've not yet seen evidence of it doing anything useful:

sqlite3.enable_callback_tracebacks(True)

I think enable_callback_tracebacks() is a good enough fix here.