diff options
author | Björn Gustavsson <[email protected]> | 2013-03-25 11:44:18 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-05-31 14:52:22 +0200 |
commit | a70395cd59e07a03ad003fa0cf166e1237151cb5 (patch) | |
tree | 10208bf510777ef99de2a985dc05e904f35eeac3 /lib/asn1/src/asn1ct.erl | |
parent | 6f9ebc3237cf62fb550c9417569ca78c79865b91 (diff) | |
download | otp-a70395cd59e07a03ad003fa0cf166e1237151cb5.tar.gz otp-a70395cd59e07a03ad003fa0cf166e1237151cb5.tar.bz2 otp-a70395cd59e07a03ad003fa0cf166e1237151cb5.zip |
Introduce a new mechanism for structured error handling
Diffstat (limited to 'lib/asn1/src/asn1ct.erl')
-rw-r--r-- | lib/asn1/src/asn1ct.erl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl index b41af6ab1b..15aa4efe7d 100644 --- a/lib/asn1/src/asn1ct.erl +++ b/lib/asn1/src/asn1ct.erl @@ -301,8 +301,10 @@ run_passes_1([{pass,Name,Pass}|Passes], #st{run=Run}=St0) try Run(Name, Pass, St0) of {ok,St} -> run_passes_1(Passes, St); - {error,#st{error=Error}} -> - {error,Error}; + {error,#st{error=Errors}} -> + {Structured,AllErrors} = clean_errors(Errors), + print_structured_errors(Structured), + {error,AllErrors}; done -> ok catch @@ -315,6 +317,21 @@ run_passes_1([{pass,Name,Pass}|Passes], #st{run=Run}=St0) run_passes_1([], _St) -> ok. +clean_errors(Errors) when is_list(Errors) -> + F = fun({structured_error,_,_,_}) -> true; + (_) -> false + end, + {Structured0,AdHoc} = lists:partition(F, Errors), + Structured = lists:sort(Structured0), + {Structured,Structured ++ AdHoc}; +clean_errors(AdHoc) -> {[],AdHoc}. + +print_structured_errors([_|_]=Errors) -> + _ = [io:format("~ts:~w: ~ts\n", [F,L,M:format_error(E)]) || + {structured_error,{F,L},M,E} <- Errors], + ok; +print_structured_errors(_) -> ok. + compile1(File, #st{opts=Opts}=St0) -> verbose("Erlang ASN.1 version ~p, compiling ~p~n", [?vsn,File], Opts), verbose("Compiler Options: ~p~n", [Opts], Opts), |