Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align to cowboy 2.9.0 api #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixup otp25
  • Loading branch information
riccardomanfrin committed Jan 25, 2023
commit 7f8cb3f3e69579772f508538ebad98821c8c1dfd
28 changes: 14 additions & 14 deletions src/soap_server_handler.erl
Original file line number Diff line number Diff line change
@@ -98,10 +98,10 @@ new_req(Handler, Server, Options, Server_req) ->
%% function, rather than by the `init` function not being defined?
error:undef ->
{continue, soap_req:set_handler_state(New_req, Options)};
Class:Reason ->
Class:Reason:Stacktrace ->
Soap_error = #soap_error{type = server,
class = Class,
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
reason = Reason,
handler = Handler,
soap_req = New_req,
@@ -136,15 +136,15 @@ handle_message(Message, Soap_req) ->
{ok, SoapReq2, _Tail} ->
soap_req:http_response(SoapReq2)
catch
Class:Reason ->
Class:Reason:Stacktrace ->
Soap_error =
case {Class, Reason} of
{throw, #soap_error{}} ->
Reason;
{_, _} ->
#soap_error{type = client,
class = Class,
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
reason = Reason,
handler = Handler,
handler_state = Handler_state,
@@ -316,10 +316,10 @@ xml_parser_cb_wrapped(Event, #p_state{state = _Parser_state,
%% TODO: differentiate more (perhaps improve erlsom error codes)
throw:#soap_error{} = Soap_error ->
throw(Soap_error#soap_error{soap_req = Soap_req, handler_state = Handler_state});
Class:Reason ->
Class:Reason:Stacktrace ->
throw(#soap_error{type = client,
class = Class,
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
reason = Reason,
handler = Handler,
handler_state = Handler_state,
@@ -471,11 +471,11 @@ xml_parser_cb({endElement, NS, "Body", _Prfx},
%% and encode it.
encode_soap_resp(Handler_resp)
catch
Class:Reason ->
Class:Reason:Stacktrace ->
throw(#soap_error{class = Class,
reason = Reason,
type = server,
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
description = "exception in handler module",
soap_req = Soap_req,
handler_state = Handler_s})
@@ -504,15 +504,15 @@ try_header_fun(Fun, Soap_req, Handler_s) ->
catch
error:function_clause ->
{ok, Soap_req, Handler_s};
Class:Reason ->
Class:Reason:Stacktrace ->
throw(callback_error(Class, Reason, Soap_req, Handler_s))
end.

callback_error(Class, Reason, Soap_req, Handler_s) ->
#soap_error{class = Class,
reason = Reason,
type = server,
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
description = "an unexpected error occcurred",
soap_req = Soap_req,
handler_state = Handler_s}.
@@ -539,23 +539,23 @@ get_header_parser(Handler, Namespace, Soap_req, Handler_s) ->
catch
error:function_clause ->
Default(Namespace, Soap_req, Handler_s);
Class:Reason ->
Class:Reason:Stacktrace ->
throw(#soap_error{type = server,
description = "Header parser selection error",
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
class = Class, reason = Reason})
end.

parse_event(Parser, Event, State, Type) ->
try
Parser(Event, State)
catch
Class:Reason ->
Class:Reason:Stacktrace ->
%% Presumably failing to parse is a client error (incorrect xml) - but it
%% could also be a server error, of course - we don't really know.
throw(#soap_error{type = client,
description = "Parser error (" ++ Type ++ ")",
stacktrace = erlang:get_stacktrace(),
stacktrace = Stacktrace,
class = Class, reason = Reason})
end.