* Improve error messages at the API level. Fixes issue 1286.