Add better error messages in debug mode.