Fix missing part of refactoring.
handle_error: Pass status code as string.

Also fix code that expected a string to be a bit more resilient.
Add type annotations.

Add some type annotations that would have found the int-string
problem fixed in the last commit.
Type annotations.