diff options
author | João Valverde <j@v6e.pt> | 2022-11-19 19:21:19 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-11-28 15:46:44 +0000 |
commit | a0d77e93298ab2e62600ec835099691b37fce69b (patch) | |
tree | c364f785b543b432a906d9d0779362114026ec2e /sharkd_session.c | |
parent | b4196ab772bd80f0bd95981fa4e70e884bfb8937 (diff) |
dfilter: Return an error object instead of string
Return an struct containing error information. This simplifies
the interface to more easily provide richer diagnostics in the future.
Add an error code besides a human-readable error string to allow
checking programmatically for errors in a robust manner. Currently
there is only a generic error code, it is expected to increase
in the future.
Move error location information to the struct. Change callers and
implementation to use the new interface.
Diffstat (limited to 'sharkd_session.c')
-rw-r--r-- | sharkd_session.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sharkd_session.c b/sharkd_session.c index 947f1c66cd..b34ab30f84 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -4069,26 +4069,27 @@ sharkd_session_process_check(char *buf, const jsmntok_t *tokens, int count) if (tok_filter != NULL) { - char *err_msg = NULL; dfilter_t *dfp; + df_error_t *df_err = NULL; - if (dfilter_compile(tok_filter, &dfp, &err_msg)) + if (dfilter_compile(tok_filter, &dfp, &df_err)) { if (dfp && dfilter_deprecated_tokens(dfp)) - sharkd_json_warning(rpcid, err_msg); + sharkd_json_warning(rpcid, df_err->msg); else sharkd_json_simple_ok(rpcid); dfilter_free(dfp); - g_free(err_msg); + dfilter_error_free(df_err); return 0; } else { sharkd_json_error( rpcid, -5001, NULL, - "Filter invalid - %s", err_msg + "Filter invalid - %s", df_err->msg ); + dfilter_error_free(df_err); return -5001; } } |