Better error reporting in debug mode