mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
More precise type information in a config framework error message
When an option's value is a reader-incompatible table or set, Zeek now renders the type as expressed in the script layer (e.g. "set[addr,addr]") as opposed to the internal type tag (which'd here be "table", including for sets).
This commit is contained in:
parent
421639e7a7
commit
aa9242913f
2 changed files with 8 additions and 4 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "zeek/Desc.h"
|
||||
#include "zeek/input/Manager.h"
|
||||
#include "zeek/threading/SerialTypes.h"
|
||||
|
||||
|
@ -38,7 +39,7 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
|||
if ( id->GetType()->Tag() == TYPE_RECORD ||
|
||||
! Manager::IsCompatibleType(id->GetType().get()) )
|
||||
{
|
||||
option_types[id->Name()] = std::make_tuple(TYPE_ERROR, id->GetType()->Tag());
|
||||
option_types[id->Name()] = std::make_tuple(TYPE_ERROR, id->GetType()->Tag(), id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -49,7 +50,7 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
|||
else if ( primary == TYPE_VECTOR )
|
||||
secondary = id->GetType()->AsVectorType()->Yield()->Tag();
|
||||
|
||||
option_types[id->Name()] = std::make_tuple(primary, secondary);
|
||||
option_types[id->Name()] = std::make_tuple(primary, secondary, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,8 +213,10 @@ bool Config::DoUpdate()
|
|||
|
||||
if ( std::get<0>((*typeit).second) == TYPE_ERROR )
|
||||
{
|
||||
ODesc d;
|
||||
std::get<2>((*typeit).second)->GetType()->Describe(&d);
|
||||
Warning(Fmt("Option '%s' has type '%s', which is not supported for file input. Ignoring line.",
|
||||
key.c_str(), type_name(std::get<1>((*typeit).second))));
|
||||
key.c_str(), d.Description()));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "zeek/ID.h"
|
||||
#include "zeek/input/ReaderBackend.h"
|
||||
#include "zeek/threading/formatters/Ascii.h"
|
||||
|
||||
|
@ -50,7 +51,7 @@ private:
|
|||
std::string empty_field;
|
||||
|
||||
std::unique_ptr<threading::Formatter> formatter;
|
||||
std::unordered_map<std::string, std::tuple<TypeTag, TypeTag>> option_types;
|
||||
std::unordered_map<std::string, std::tuple<TypeTag, TypeTag, zeek::detail::IDPtr>> option_types;
|
||||
std::unordered_map<std::string, std::string> option_values;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue