Skip to content

Commit 01facf2

Browse files
committed
[onert] Add API function for retrieving last error message
This commit adds dedicated API function nnfw_get_last_error_message() for retrieving last error message in case when other functions return status code other than NNFW_STATUS_NO_ERROR. ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy <[email protected]>
1 parent 098e39f commit 01facf2

File tree

5 files changed

+363
-218
lines changed

5 files changed

+363
-218
lines changed

runtime/onert/api/nnfw/include/nnfw.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ NNFW_STATUS nnfw_create_session(nnfw_session **session);
212212
*/
213213
NNFW_STATUS nnfw_close_session(nnfw_session *session);
214214

215+
/**
216+
* @brief Get the last error message
217+
*
218+
* This function retrieves the last error message occurred in the session.
219+
*
220+
* @param[in] session session to be queried on.
221+
* @return The last error message string. The returned pointer is valid only
222+
* until the next API call with the same session.
223+
*/
224+
const char *nnfw_get_last_error_message(nnfw_session *session);
225+
215226
/**
216227
* @brief Load model from path to model or nnpackage
217228
*

runtime/onert/api/nnfw/src/APIImpl.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ NNFW_STATUS nnfw_close_session(nnfw_session *session)
6969
return NNFW_STATUS_NO_ERROR;
7070
}
7171

72+
const char *nnfw_get_last_error_message(nnfw_session *session)
73+
{
74+
if (session == NULL)
75+
return "Session is NULL";
76+
return reinterpret_cast<Session *>(session)->get_last_error_message().c_str();
77+
}
78+
7279
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *path)
7380
{
7481
NNFW_RETURN_ERROR_IF_NULL(session);

0 commit comments

Comments
 (0)