Skip to content

Commit 64f52bf

Browse files
committed
feat: improved cannot open model file error.
1 parent 4d2b862 commit 64f52bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/llm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "nn/nn-network.hpp"
55
#include "mmap.hpp"
66
#include "llm.hpp"
7+
#include <cerrno>
78
#include <stdexcept>
89

910
static const char *hiddenActToString(LlmHiddenAct act) {
@@ -46,7 +47,7 @@ LlmHeader loadLlmHeader(const char *path, const NnUint maxSeqLen, NnFloatType sy
4647
std::unique_ptr<FILE, int(*)(FILE *)> fdPtr(fopen(path, "rb"), fclose);
4748
FILE *fd = fdPtr.get();
4849
if (fd == NULL)
49-
throw std::runtime_error("Cannot open model file");
50+
throw std::runtime_error(std::string("Cannot open model file (") + path + std::string("): ") + std::strerror(errno));
5051

5152
int magic;
5253
if (fread(&magic, sizeof(int), 1, fd) != 1)

0 commit comments

Comments
 (0)