From 70bb24b6eec441b3235c411b4fd9efd779992e8d Mon Sep 17 00:00:00 2001 From: Bikram Chatterjee Date: Wed, 18 Apr 2018 22:10:14 +0200 Subject: [PATCH] #189 catch all preprocessor erros --- src/imem_compiler.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/imem_compiler.erl b/src/imem_compiler.erl index d3fb9dd..1bad3fe 100644 --- a/src/imem_compiler.erl +++ b/src/imem_compiler.erl @@ -174,12 +174,14 @@ compile_mod(ModuleCodeBinStr, Restrict, Opts) when is_binary(ModuleCodeBinStr) - tokenize(ModuleCodeBinStr) -> case erl_scan:string(binary_to_list(ModuleCodeBinStr), {0,1}) of {ok, RawTokens, _} -> - case aleppo:process_tokens(RawTokens) of + case catch aleppo:process_tokens(RawTokens) of {ok, TokensEOF} -> [{eof,_} | RevTokens] = lists:reverse(TokensEOF), Tokens = lists:reverse(RevTokens), {ok, cut_dot(Tokens)}; {error, Error} -> + {error, {preprocess, {{0, 1}, ?MODULE, Error}, {0, 1}}}; + {'EXIT', Error} -> {error, {preprocess, {{0, 1}, ?MODULE, Error}, {0, 1}}} end; {error, ErrorInfo, ErrorLocation} ->