Fix bug in error handler when response is None

Regression introduced in #298.

cc @danielgtaylor