Skip to content

Commit

Permalink
return proper error when the model path isn't found (#2391)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinb35 authored Nov 13, 2019
1 parent a3a6a97 commit 895342b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions winml/lib/Api.Core/ModelInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,22 @@ std::unique_ptr<onnx::ModelProto>
WinML::CreateModelProto(
const char* path) {
int file_descriptor;
_set_errno(0); // clear errno
_sopen_s(
&file_descriptor,
path,
O_RDONLY | _O_SEQUENTIAL | _O_BINARY,
_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,
Expand Down

0 comments on commit 895342b

Please sign in to comment.