pisa
pisa copied to clipboard
Always check if path exists
We have many places where we just assume that a file exists, say, when we create a mio::mmap_source
, which then fails with simply No such file exists
or something similar if the file is missing. It's difficult to debug, and more importantly, it's very confusing to the end user. We should at least have a function resolve_path(str)
that throws a more informative error message. We can also think of having another function resolve_path(path, msgfmt, args...)
that would use fmt
to display message, and some specialized functions that repeat many times, say:
auto resolve_term_lexicon_path(std::string_view path) {
return resolve_path(path, "Missing term lexicon file: {}", path);
}
But I'm also open to other suggestions.
+1, sounds like a nice idea.