Ensure we have a valid HTTP status code

- Added a method to either use the code in a given exception, or, if outside the
  range of accepted codes or non-integer, return 500.
- Updated places where an ApiProblem is created from an exception to use the
  above method.