http_errors.erl 578 B

12345678910111213141516171819
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_errors).
  3. -export([init/2]).
  4. -spec init(_, _) -> no_return().
  5. init(Req, _Opts) ->
  6. #{'case' := Case} = cowboy_req:match_qs(['case'], Req),
  7. case_init(Case, Req).
  8. -spec case_init(_, _) -> no_return().
  9. case_init(<<"init_before_reply">> = Case, _Req) ->
  10. ct_helper_error_h:ignore(?MODULE, case_init, 2),
  11. error(Case);
  12. case_init(<<"init_after_reply">> = Case, Req) ->
  13. ct_helper_error_h:ignore(?MODULE, case_init, 2),
  14. _ = cowboy_req:reply(200, #{}, "http_handler_crashes", Req),
  15. error(Case).