namespace ml {
namespace util {
+PlatformResult ToPlatformResult(int ml_error_code, const std::string& error_message_beginning) {
+ ScopeLogger("ml_error_code: [%d] (%s)", ml_error_code, get_error_message(ml_error_code));
+
+ switch (ml_error_code) {
+ case ML_ERROR_NONE:
+ return PlatformResult{};
+ case ML_ERROR_INVALID_PARAMETER:
+ return PlatformResult{ErrorCode::INVALID_VALUES_ERR,
+ error_message_beginning + ": invalid parameter"};
+ case ML_ERROR_PERMISSION_DENIED:
+ return PlatformResult{ErrorCode::SECURITY_ERR,
+ error_message_beginning + ": permission denied"};
+ case ML_ERROR_TRY_AGAIN:
+ return PlatformResult{ErrorCode::INVALID_STATE_ERR,
+ error_message_beginning + ": invalid state"};
+ case ML_ERROR_TIMED_OUT:
+ return PlatformResult{ErrorCode::TIMEOUT_ERR, error_message_beginning + ": timeout"};
+ case ML_ERROR_NOT_SUPPORTED:
+ return PlatformResult{ErrorCode::NOT_SUPPORTED_ERR,
+ error_message_beginning + ": not supported"};
+ case ML_ERROR_STREAMS_PIPE:
+ case ML_ERROR_UNKNOWN:
+ case ML_ERROR_OUT_OF_MEMORY:
+ default:
+ return PlatformResult{ErrorCode::ABORT_ERR,
+ error_message_beginning + ": an unknown error occurred"};
+ }
+}
+
using namespace common;
} // util
#ifndef ML_ML_UTILS_H_
#define ML_ML_UTILS_H_
+#include <nnstreamer/nnstreamer.h>
+
#include "common/picojson.h"
#include "common/platform_result.h"
+using common::PlatformResult;
+using common::ErrorCode;
+
namespace extension {
namespace ml {
-namespace util {} // util
+namespace util {
+
+PlatformResult ToPlatformResult(int ml_error_code, const std::string& error_message);
+
+} // util
} // ml
} // extension