代码拉取完成,页面将自动刷新
654
增加统一的错误异常封装方法
已合并
相关的Issue
原因(目的、解决的问题等)
按照最新的异常处理规范,所有的JS API如果涉及抛出异常的,必须按照以下格式抛出合适的错误对象;
{
code: 100001, // the error code
message: "error details" // the error message
data: {} // more error info, this is optional
}
描述(做了什么,变更了什么)
新增了 JSI::CreateErrorWithCode接口方法 JS API 模块用来创建自己的异常对象;
/**
* @brief Create javascript error object with error code and error message.
* This interface can be used to create one uniform error object, which can be throw to JS API caller,
* The error object's structure is shown as following,
* {
* code: 100001, // the error code
* message: "error details" // the error message
* data: {} // more error info, this is optional
* }
*
* @param [in] errCode: the error code which can indicate
* @param [in] errorMsg: value of 'message' property of constructed error object
* @param [in] extraErrData: value of 'data' property of constructed error object, which is optional,
* if it's given by caller, it must be one object, and it should be released by caller itself
* @return value of the constructed error object
*
* value returned should be released by caller with ReleaseValue when it won't be used any more
*/
static JSIValue CreateErrorWithCode(uint32_t errCode,
const char * const errMsg,
const JSIValue extraErrData = 0);
测试用例(新增、改动、可能影响的功能)
JsiInterfaceTddTest::JSIInterfaceTest030
JsiInterfaceTddTest::JSIInterfaceTest031
JsiInterfaceTddTest::JSIInterfaceTest032
JsiInterfaceTddTest::JSIInterfaceTest033
JsiInterfaceTddTest::JSIInterfaceTest034
JsiInterfaceTddTest::JSIInterfaceTest035
JsiInterfaceTddTest::JSIInterfaceTest036
JsiInterfaceTddTest::JSIInterfaceTest037
JsiInterfaceTddTest::JSIInterfaceTest038