improved error messages

* If the server returns an error, throw the error message instead of the status code.
* Name all functions, so that "anonymous function" never appears in the stack trace.