Fix error reporting bug