mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
return proper error when the model path isn't found (#2391)
This commit is contained in:
parent
a3a6a97407
commit
895342bf74
1 changed files with 9 additions and 0 deletions
|
|
@ -137,6 +137,7 @@ std::unique_ptr<onnx::ModelProto>
|
|||
WinML::CreateModelProto(
|
||||
const char* path) {
|
||||
int file_descriptor;
|
||||
_set_errno(0); // clear errno
|
||||
_sopen_s(
|
||||
&file_descriptor,
|
||||
path,
|
||||
|
|
@ -144,6 +145,14 @@ WinML::CreateModelProto(
|
|||
_SH_DENYWR,
|
||||
_S_IREAD | _S_IWRITE);
|
||||
|
||||
errno_t err = 0;
|
||||
_get_errno(&err);
|
||||
WINML_THROW_HR_IF_TRUE_MSG(
|
||||
__HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
|
||||
err == ENOENT,
|
||||
"File not found: %s",
|
||||
path);
|
||||
|
||||
WINML_THROW_HR_IF_TRUE_MSG(
|
||||
E_FAIL,
|
||||
0 > file_descriptor,
|
||||
|
|
|
|||
Loading…
Reference in a new issue