1 %% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
2 %%%---------------------------------------------------------------------------
3 %%% @author Eric Merritt
5 %%% A utility to help format sinan exceptions
7 %%% @copyright 2011 Erlware
8 %%%---------------------------------------------------------------------------
9 -module(sin_exceptions
).
12 -export([format_exception
/1]).
13 -export_type([reason
/0, exception
/0]).
16 %%====================================================================
18 %%====================================================================
20 -type
reason() :: {atom(), string()} | atom().
21 -type
exception() :: {module(), non_neg_integer(), reason()}.
23 %%====================================================================
25 %%====================================================================
27 %% @doc a helper function to format sinan formated exceptions
28 -spec
format_exception(exception()) -> string().
29 format_exception({pe
, _
, {Module
, Line
, {Reason
, Description
}}})
30 when is_list(Reason
) ->
31 io_lib:format("~s:~p [~p] ~s", [Module
, Line
, Reason
,
32 lists:flatten(Description
)]);
33 format_exception({pe
, _
, {Module
, Line
, Reason
}}) ->
34 io_lib:format("~s:~p [~p]", [Module
, Line
, Reason
]).