Skip to content

Conversation

@ankitm3k
Copy link

This PR enables exceptions handling during compilation failure raising ORT_EP_FAIL Error Code & Import Flow failure raises ORT_INVALID_GRAPH Error Code.

JIRA -
https://jira.devtools.intel.com/browse/CVS-167480

@ankitm3k ankitm3k force-pushed the ankit/ort_error_codes_handling branch from 714c56f to 5de6981 Compare November 3, 2025 06:45
@ankitm3k ankitm3k force-pushed the ankit/ort_error_codes_handling branch from 5de6981 to f4fc10a Compare November 4, 2025 04:48
@ankitm3k
Copy link
Author

ankitm3k commented Nov 5, 2025

@MayureshV1 & @javier-intel please review & merge this PR too in conjunction to PR https://github.com/intel-innersource/frameworks.ai.onnxruntime.staging/pull/182

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements structured error code handling for OpenVINO execution provider by encoding ORT error codes in exception messages during model import and compilation flows. The changes enable differentiation between import failures (ORT_INVALID_GRAPH) and compilation failures (ORT_EP_FAIL).

  • Added error code parameter to OvExceptionBoundary template function with default ORT_EP_FAIL
  • Encoded error codes as message prefix using "|message" pattern
  • Updated compute function to extract and use encoded error codes from exceptions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
onnxruntime/core/providers/openvino/ov_interface.cc Added error code parameter to exception boundary with message encoding; specified ORT_INVALID_GRAPH for import failures
onnxruntime/core/providers/openvino/openvino_execution_provider.cc Added error code extraction logic in compute function to parse encoded error codes from exception messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return code;
return static_cast<int>(common::EP_FAIL);
};
return common::Status(common::ONNXRUNTIME, get_error_code(ex.what()), ex.what());
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message returned includes the encoded prefix (e.g., '1234|message'), which will be displayed to users. Consider extracting only the message portion after the '|' delimiter when constructing the Status to provide cleaner error messages.

Suggested change
return common::Status(common::ONNXRUNTIME, get_error_code(ex.what()), ex.what());
auto get_error_message = [](std::string_view msg) {
if (auto pos = msg.find('|'); pos != std::string_view::npos)
return std::string(msg.substr(pos + 1));
return std::string(msg);
};
return common::Status(common::ONNXRUNTIME, get_error_code(ex.what()), get_error_message(ex.what()));

Copilot uses AI. Check for mistakes.
Comment on lines +181 to +183
if (auto pos = msg.find('|'); pos != std::string_view::npos)
if (int code = 0; std::from_chars(msg.data(), msg.data() + pos, code).ec == std::errc{})
return code;
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The nested if statements make the error code extraction logic difficult to read. Consider using early returns or splitting into separate conditions for better clarity.

Suggested change
if (auto pos = msg.find('|'); pos != std::string_view::npos)
if (int code = 0; std::from_chars(msg.data(), msg.data() + pos, code).ec == std::errc{})
return code;
auto pos = msg.find('|');
if (pos == std::string_view::npos) {
return static_cast<int>(common::EP_FAIL);
}
int code = 0;
auto result = std::from_chars(msg.data(), msg.data() + pos, code);
if (result.ec == std::errc{}) {
return code;
}

Copilot uses AI. Check for mistakes.
@MayureshV1
Copy link

@ankitm3k .. Can you consider porting the goodness from the previous effort that was put in to report these error codes. This also gives us the option to report out granular errors from the lower stack whom we worked with to get it implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants