diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-11-09 08:42:40 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-11-09 08:42:40 +0000 |
| commit | a2d78941ba8d199ffbaa4b7b102a45312c78fcf7 (patch) | |
| tree | ef7ff3613b5b82ab2f0fe707994bc899b1d05de9 /src | |
| parent | 12abb54a8853b50df5815387946dbae8cf7dc448 (diff) | |
Catch expression evaluation errors in line/column highlighters
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index 17f32cf4..a2e8e662 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -478,14 +478,24 @@ HighlighterAndId create_line_highlighter(HighlighterParameters params) throw runtime_error("wrong parameter count"); String facespec = params[1]; - String option_name = params[0]; + String line_expr = params[0]; get_face(facespec); // validate facespec auto func = [=](const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange) { - const LineCount line = str_to_int_ifp(expand(option_name, context)).value_or(0) - 1; + LineCount line = -1; + try + { + line = str_to_int_ifp(expand(line_expr, context)).value_or(0) - 1; + } + catch (runtime_error& err) + { + write_to_debug_buffer( + format("Error evaluating highlight line expression: {}", err.what())); + } + if (line < 0) return; @@ -520,14 +530,24 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params) throw runtime_error("wrong parameter count"); String facespec = params[1]; - String option_name = params[0]; + String col_expr = params[0]; get_face(facespec); // validate facespec auto func = [=](const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange) { - const CharCount column = str_to_int_ifp(expand(option_name, context)).value_or(0) - 1; + CharCount column = -1; + try + { + column = str_to_int_ifp(expand(col_expr, context)).value_or(0) - 1; + } + catch (runtime_error& err) + { + write_to_debug_buffer( + format("Error evaluating highlight column expression: {}", err.what())); + } + if (column < 0) return; |
