Chapter 14 "Creating custom errors"

turns out that using the code suggested won’t work here as error already handled in the RxCocoa Extension on URLSession, or do I missed something?!

   return session.rx.response(request: request).map() { response, data in
      if 200 ..< 300 ~= response.statusCode {
        return JSON(data: data)
      } else if 400 ..< 500 ~= response.statusCode {
        throw ApiError.cityNotFound
     } else {
      throw ApiError.serverFailure
     }
  }

Obviously missed something. :man_facepalming:

In case you got no response or no data or (2nd case the response is an HTTPURLResponse) … then you bypass your own error code handling which makes sense because our own error handling is based on data or an response with statusCode. Sry.

@bontojr Can you please help with this when you get a chance? Thank you - much appreciated! :]