diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-05-09 17:46:54 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-05-11 18:18:35 +0200 |
commit | d486c9e626405e829221b82d7355558005b26d8a (patch) | |
tree | a704df09df488b31302a9c6caa7bd855c295baa2 /include | |
parent | 8d586177b843af5e77f10e3f0c532341648582d0 (diff) |
datatype: add hint error handler
If user provides a symbol that cannot be parsed and the datatype provides
an error handler, provide a hint through the misspell infrastructure.
For instance:
# cat test.nft
table ip x {
map y {
typeof ip saddr : verdict
elements = { 1.2.3.4 : filter_server1 }
}
}
# nft -f test.nft
test.nft:4:26-39: Error: Could not parse netfilter verdict; did you mean `jump filter_server1'?
elements = { 1.2.3.4 : filter_server1 }
^^^^^^^^^^^^^^
While at it, normalize error to "Could not parse symbolic %s expression".
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/datatype.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/datatype.h b/include/datatype.h index 391d6ac8..4b59790b 100644 --- a/include/datatype.h +++ b/include/datatype.h @@ -167,6 +167,7 @@ struct datatype { struct error_record *(*parse)(struct parse_ctx *ctx, const struct expr *sym, struct expr **res); + struct error_record *(*err)(const struct expr *sym); void (*describe)(struct output_ctx *octx); const struct symbol_table *sym_tbl; unsigned int refcnt; |