Skip to content

RestCore::JsonResponse::ParseError on non-success http status code #16

@wvengen

Description

@wvengen

With the following middleware:

  use RC::ErrorHandler  , lambda {|env| RuntimeError.new(env[RC::RESPONSE_BODY]['message']) }
  use RC::ErrorDetector , lambda {|env| env[RC::RESPONSE_BODY]['status'] != 'ok'}
  use RC::ErrorDetectorHttp
  use RC::JsonResponse  , true

and a request that returns a non-success http status code returning an html error page, JsonResponse can't parse the response.

Moving the JsonResponse middleware to before the ErrorHandler (not just ErrorDetectorHttp) solves this problem, but then the ErrorDetector and ErrorHandler can't be used because at that moment the body hasn't been parsed yet.

Any idea how to solve this nicely?

(Somewhat similar to #8.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions