Improve error message, based ona patch from Brad Langhorst