WriteError writes an error to the response as a JSON object.
If the error is an instance of Error, the status code will be set to the error's code.
Otherwise, it will return a 400 status code.
Handler is similar to http.HandlerFunc with simple error handling built in.
If an error is returned, it will be written to the response as a JSON object (using WriteError).