api.request: fix error reporting when request fails before getting any response

As pointed out in #10, introduced in 90114a9 (for #8).