Minor error handling improvements

This commit is contained in:
Henri DF 2016-03-29 19:31:34 -07:00
parent 019e76114e
commit aea9b0054b
4 changed files with 11 additions and 2 deletions

View File

@ -114,7 +114,7 @@ void do_inspect(sinsp* inspector,
if(lua_pcall(ls, 2, 0, 0) != 0)
{
const char* lerr = lua_tostring(ls, -1);
string err = "Error installing rules: " + string(lerr);
string err = "Error invoking function output: " + string(lerr);
throw sinsp_exception(err);
}
}

View File

@ -47,7 +47,7 @@ int digwatch_fields::field(lua_State *ls)
if(chk == NULL)
{
string err = "nonexistent fieldname passed to digwatch.field()" + string(fieldname);
string err = "nonexistent fieldname passed to digwatch.field(): " + string(fieldname);
fprintf(stderr, "%s\n", err.c_str());
throw sinsp_exception("digwatch.field() error");
}

View File

@ -24,6 +24,11 @@ function mod.first_sequence(evt, fieldname, key, format)
msg = digwatch.format_event(evt, formatter)
print (msg)
end
if field_value == nil then
formatter = digwatch.formatter(format)
s = digwatch.format_event(evt, formatter)
error("first_sequence: field '"..fieldname.."' is nil in event ("..s..")")
end
first_sequence_state[key][field_value] = now
end

View File

@ -164,6 +164,10 @@ end
evt = nil
function on_event(evt_, rule_id)
if state.outputs[rule_id] == nil then
error ("rule_loader.on_event(): event with invalid rule_id: ", rule_id)
end
if state.outputs[rule_id].type == "format" then
print(digwatch.format_event(evt_, state.outputs[rule_id].formatter))
elseif state.outputs[rule_id].type == "function" then