dlhandle: suppress DLL errors on Windows (#2389)

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel
2024-05-31 16:33:40 -04:00
committed by GitHub
parent 4e89a9c44f
commit 8ba7ef4832
2 changed files with 28 additions and 9 deletions

View File

@@ -141,12 +141,18 @@ const std::vector<LLModel::Implementation> &LLModel::Implementation::implementat
if (!std::regex_search(p.stem().string(), re)) continue;
// Add to list if model implementation
Dlhandle dl;
try {
Dlhandle dl(p);
if (!isImplementation(dl))
continue;
fres.emplace_back(Implementation(std::move(dl)));
} catch (...) {}
dl = Dlhandle(p);
} catch (const Dlhandle::Exception &e) {
std::cerr << "Failed to load " << p.filename().string() << ": " << e.what() << "\n";
continue;
}
if (!isImplementation(dl)) {
std::cerr << "Not an implementation: " << p.filename().string() << "\n";
continue;
}
fres.emplace_back(Implementation(std::move(dl)));
}
}
};