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

Save Twilio errors information #758

Merged
merged 5 commits into from
Nov 4, 2016
Merged

Save Twilio errors information #758

merged 5 commits into from
Nov 4, 2016

Conversation

spalladino
Copy link
Contributor

Any errors when issuing a Twilio outgoing call (such as an invalid number) are now captured and displayed in the call log details, along with a link to the Twilio documentation for more information.

Fixes #742

The code should be identified as ISDN from the Asterisk PBX module, not in the common call_log_srv which is shared with Twilio.
Store them as fail_reason and fail_code.
Previously only ISDN asterisk errors were being shown and linked.
end
catch
_ -> Reason
end.
Copy link
Member

@ggiraldez ggiraldez Nov 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably better to use xmerl_xs here. See http://erlang.org/doc/man/xmerl_xs.html

Something like:

parse_exception(Reason, Body) ->
  try
    {Doc, []} = xmerl_scan:string(Body),
    [Exception] = xmerl_xs:select("/TwilioResponse/RestException", Doc),
    FullCode = case xmerl_xs:value_of(xmerl_xs:select("./Code", Exception)) of
      [Code] -> "twilio" ++ Code;
      _ -> undefined
    end,
    [Message] = xmerl_xs:value_of(xmerl_xs:select("./Message", Exception)),
    {error, Message, FullCode}
  catch
    _ -> Reason
  end.

@spalladino spalladino merged commit a5a4528 into master Nov 4, 2016
@spalladino spalladino deleted the feature/twilio-errors branch November 4, 2016 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants