pisa icon indicating copy to clipboard operation
pisa copied to clipboard

Always check if path exists

Open elshize opened this issue 4 years ago • 1 comments

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.

elshize avatar Apr 06 '20 15:04 elshize

+1, sounds like a nice idea.

JMMackenzie avatar Apr 06 '20 23:04 JMMackenzie