Return error code for unknown errors
Enable detailed errors if they're available

Fixes #46, fixes #52