ReportPredefinedErrMsg

Description

Reports user error information predefined by CANN.

Prototype

  • Error code information without parameters:
    int32_t ReportPredefinedErrMsg(const char *error_code)
  • Error code information with parameters:
    int32_t ReportPredefinedErrMsg(const char *error_code, const std::vector<const char *> &key, const std::vector<const char *> &value)

The macro REPORT_PREDEFINED_ERR_MSG for encapsulating this API is also provided. The macro definition is as follows:

#define REPORT_PREDEFINED_ERRMSG_CHOOSER(_1, _2, _3, NAME, ...) NAME
#define REPORT_PREDEFINED_ERRMSG_1PARAMS(error_code) error_message::ReportPredefinedErrMsg(error_code)
#define REPORT_PREDEFINED_ERRMSG_3PARAMS(error_code, key, value)                                                       \
  error_message::ReportPredefinedErrMsg((error_code), (key), (value))
#define REPORT_PREDEFINED_ERR_MSG(...)                                                                                 \
  REPORT_PREDEFINED_ERRMSG_CHOOSER(__VA_ARGS__, REPORT_PREDEFINED_ERRMSG_3PARAMS, ,                                    \
                                   REPORT_PREDEFINED_ERRMSG_1PARAMS)(__VA_ARGS__)

Parameters

Parameter

Input/Output

Description

error_code

Input

An error code consists of six characters, for example, E10001. The first character indicates the level, which can be E (error), W (warning), or I (info). The second character indicates the module. The last four characters indicate the error code. Error codes 0000 to 8999 are user error codes.

For details about user errors predefined by CANN, see Error Codes in Troubleshooting.

key

Input

Predefined parameter.

For details about the parameters supported by each error code, see the Arglist field in the error_code.json file.

value

Input

Actual value of the parameter in key.

The actual value will replace the placeholder of the ErrMessage field in the error_code.json file to obtain the final error code information.

Returns

  • 0: success
  • -1: failure