diff options
Diffstat (limited to '')
-rw-r--r-- | src/regexp_vtab.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/regexp_vtab.cc b/src/regexp_vtab.cc index 5324194..d992ea9 100644 --- a/src/regexp_vtab.cc +++ b/src/regexp_vtab.cc @@ -31,6 +31,7 @@ # include <alloca.h> #endif +#include "base/lnav.console.into.hh" #include "base/lnav_log.hh" #include "column_namer.hh" #include "config.h" @@ -39,10 +40,13 @@ #include "scn/scn.h" #include "sql_help.hh" #include "sql_util.hh" +#include "sqlitepp.hh" #include "vtab_module.hh" #include "yajlpp/yajlpp.hh" #include "yajlpp/yajlpp_def.hh" +namespace { + enum { RC_COL_MATCH_INDEX, RC_COL_INDEX, @@ -238,9 +242,12 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor, auto pattern = from_sqlite<string_fragment>()(argc, argv, 1); auto compile_res = lnav::pcre2pp::code::from(pattern); if (compile_res.isErr()) { - pVtabCursor->pVtab->zErrMsg - = sqlite3_mprintf("Invalid regular expression: %s", - compile_res.unwrapErr().get_message().c_str()); + static const intern_string_t PATTERN_SRC + = intern_string::lookup("pattern"); + + set_vtable_errmsg(pVtabCursor->pVtab, + lnav::console::to_user_message( + PATTERN_SRC, compile_res.unwrapErr())); return SQLITE_ERROR; } @@ -486,9 +493,12 @@ rcjFilter(sqlite3_vtab_cursor* pVtabCursor, auto pattern = from_sqlite<string_fragment>()(argc, argv, 1); auto compile_res = lnav::pcre2pp::code::from(pattern); if (compile_res.isErr()) { - pVtabCursor->pVtab->zErrMsg - = sqlite3_mprintf("Invalid regular expression: %s", - compile_res.unwrapErr().get_message().c_str()); + static const intern_string_t PATTERN_SRC + = intern_string::lookup("pattern"); + + set_vtable_errmsg(pVtabCursor->pVtab, + lnav::console::to_user_message( + PATTERN_SRC, compile_res.unwrapErr())); return SQLITE_ERROR; } @@ -508,8 +518,7 @@ rcjFilter(sqlite3_vtab_cursor* pVtabCursor, "unable to parse flags") .with_reason(parse_res.unwrapErr()[0]); - pVtabCursor->pVtab->zErrMsg = sqlite3_mprintf( - "%s%s", sqlitepp::ERROR_PREFIX, lnav::to_json(um).c_str()); + set_vtable_errmsg(pVtabCursor->pVtab, um); return SQLITE_ERROR; } @@ -542,6 +551,8 @@ rcjFilter(sqlite3_vtab_cursor* pVtabCursor, return SQLITE_OK; } +} // namespace + int register_regexp_vtab(sqlite3* db) { |