| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 22-Oct-2025 | - | 35 | 32 | ||
| createerror/ | 22-Oct-2025 | - | 703 | 583 | ||
| createrangeerror/ | 22-Oct-2025 | - | 622 | 510 | ||
| createsyntaxerror/ | 22-Oct-2025 | - | 622 | 510 | ||
| createtypeerror/ | 22-Oct-2025 | - | 621 | 510 | ||
| getandclearlastexception/ | 22-Oct-2025 | - | 619 | 507 | ||
| getlasterrorinfo/ | 22-Oct-2025 | - | 628 | 513 | ||
| hvigor/ | 22-Oct-2025 | - | 38 | 36 | ||
| iserror/ | 22-Oct-2025 | - | 627 | 514 | ||
| isexceptionpending/ | 22-Oct-2025 | - | 634 | 520 | ||
| screenshots/ | 22-Oct-2025 | - | ||||
| throwerror/ | 22-Oct-2025 | - | 649 | 532 | ||
| throwrangeerror/ | 22-Oct-2025 | - | 645 | 528 | ||
| throwsyntaxerror/ | 22-Oct-2025 | - | 650 | 532 | ||
| throwtypeerror/ | 22-Oct-2025 | - | 648 | 532 | ||
| .gitignore | D | 22-Oct-2025 | 144 | 12 | 12 | |
| README.md | D | 22-Oct-2025 | 12.1 KiB | 284 | 262 | |
| build-profile.json5 | D | 22-Oct-2025 | 4 KiB | 190 | 188 | |
| code-linter.json5 | D | 22-Oct-2025 | 992 | 35 | 34 | |
| hvigorfile.ts | D | 22-Oct-2025 | 864 | 22 | 5 | |
| oh-package.json5 | D | 22-Oct-2025 | 834 | 26 | 24 | |
| ohosTest.md | D | 22-Oct-2025 | 2.6 KiB | 21 | 18 |
README.md
1# ArkTs使用JSVM-API接口进行错误处理开发 2 3### 介绍 4 5使用JSVM-API接口进行错误处理开发,使得在JSVM-API模块中能够更好地管理和响应错误情况。通过合理使用这些函数,可以提高模块的稳定性和可靠性。 6 7该工程中展示的代码详细描述可查如下链接: 8 9- [使用JSVM-API接口进行错误处理开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-error.md) 10 11### 效果预览 12 13| 首页 | 执行及结果即时反馈 | 14| :-----------------------------------------------------------: | :-----------------------------------------------------------: | 15| <img src="./screenshots/JsvmError_1.png" style="zoom:33%;" /> | <img src="./screenshots/JsvmError_2.png" style="zoom:33%;" /> | 16 17### 使用说明 18 191. 在主界面,可以点击Hello World,开始执行。 202. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 21 22### 工程目录 23 24``` 25createerror/src/ 26 ├── main 27 │ ├── cpp 28 │ │ ├── types 29 │ │ │ ├── libentry 30 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 31 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 32 │ │ ├── CMakeLists.txt // 配置CMake打包参数 33 │ │ ├── hello.cpp // 实现Native侧的runTest接口 34 │ ├── ets 35 │ │ ├── entryability 36 │ │ ├── entrybackupability 37 │ │ ├── pages 38 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 39 │ ├── module.json5 40 │ └── resources 41 ├── ohosTest 42 │ ├── ets 43 │ │ ├── test 44 │ │ ├── Ability.test.ets // 自动化测试代码 45createrangeerror/src/ 46 ├── main 47 │ ├── cpp 48 │ │ ├── types 49 │ │ │ ├── libcreaterangeerror 50 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 51 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 52 │ │ ├── CMakeLists.txt // 配置CMake打包参数 53 │ │ ├── hello.cpp // 实现Native侧的runTest接口 54 │ ├── ets 55 │ │ ├── createrangeerrorability 56 │ │ ├── pages 57 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 58 │ ├── module.json5 59 │ └── resources 60 ├── ohosTest 61 │ ├── ets 62 │ │ ├── test 63 │ │ ├── Ability.test.ets // 自动化测试代码 64createsyntaxerror/src/ 65 ├── main 66 │ ├── cpp 67 │ │ ├── types 68 │ │ │ ├── libcreatesyntaxerror 69 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 70 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 71 │ │ ├── CMakeLists.txt // 配置CMake打包参数 72 │ │ ├── hello.cpp // 实现Native侧的runTest接 73 │ ├── ets 74 │ │ ├── createsyntaxerrorability 75 │ │ ├── pages 76 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 77 │ ├── module.json5 78 │ └── resources 79 ├── ohosTest 80 │ ├── ets 81 │ │ ├── test 82 │ │ ├── Ability.test.ets // 自动化测试代码 83createtypeerror/src/ 84 ├── main 85 │ ├── cpp 86 │ │ ├── types 87 │ │ │ ├── libcreatetypeerror 88 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 89 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 90 │ │ ├── CMakeLists.txt // 配置CMake打包参数 91 │ │ ├── hello.cpp // 实现Native侧的runTest接 92 │ ├── ets 93 │ │ ├── createtypeerrorability 94 │ │ ├── entrybackupability 95 │ │ ├── pages 96 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 97 │ ├── module.json5 98 │ └── resources 99 ├── ohosTest 100 │ ├── ets 101 │ │ ├── test 102 │ │ ├── Ability.test.ets // 自动化测试代码 103getandclearlastexception/src/ 104 ├── main 105 │ ├── cpp 106 │ │ ├── types 107 │ │ │ ├── libgetandclearlastexception 108 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 109 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 110 │ │ ├── CMakeLists.txt // 配置CMake打包参数 111 │ │ ├── hello.cpp // 实现Native侧的runTest接 112 │ ├── ets 113 │ │ ├── getandclearlastexceptionability 114 │ │ ├── pages 115 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 116 │ ├── module.json5 117 │ └── resources 118 ├── ohosTest 119 │ ├── ets 120 │ │ ├── test 121 │ │ ├── Ability.test.ets // 自动化测试代码 122getlasterrorinfo/src/ 123 ├── main 124 │ ├── cpp 125 │ │ ├── types 126 │ │ │ ├── libgetlasterrorinfo 127 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 128 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 129 │ │ ├── CMakeLists.txt // 配置CMake打包参数 130 │ │ ├── hello.cpp // 实现Native侧的runTest接 131 │ ├── ets 132 │ │ ├── getlasterrorinfoability 133 │ │ ├── pages 134 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 135 │ ├── module.json5 136 │ └── resources 137 ├── ohosTest 138 │ ├── ets 139 │ │ ├── test 140 │ │ ├── Ability.test.ets // 自动化测试代码 141iserror/src/ 142 ├── main 143 │ ├── cpp 144 │ │ ├── types 145 │ │ │ ├── libiserror 146 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 147 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 148 │ │ ├── CMakeLists.txt // 配置CMake打包参数 149 │ │ ├── hello.cpp // 实现Native侧的runTest接 150 │ ├── ets 151 │ │ ├── iserrorability 152 │ │ ├── pages 153 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 154 │ ├── module.json5 155 │ └── resources 156 ├── ohosTest 157 │ ├── ets 158 │ │ ├── test 159 │ │ ├── Ability.test.ets // 自动化测试代码 160isexceptionpending/src/ 161 ├── main 162 │ ├── cpp 163 │ │ ├── types 164 │ │ │ ├── libisexceptionpending 165 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 166 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 167 │ │ ├── CMakeLists.txt // 配置CMake打包参数 168 │ │ ├── hello.cpp // 实现Native侧的runTest接 169 │ ├── ets 170 │ │ ├── isexceptionpendingability 171 │ │ ├── pages 172 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 173 │ ├── module.json5 174 │ └── resources 175 ├── ohosTest 176 │ ├── ets 177 │ │ ├── test 178 │ │ ├── Ability.test.ets // 自动化测试代码 179throwerror/src/ 180 ├── main 181 │ ├── cpp 182 │ │ ├── types 183 │ │ │ ├── libthrowerror 184 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 185 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 186 │ │ ├── CMakeLists.txt // 配置CMake打包参数 187 │ │ ├── hello.cpp // 实现Native侧的runTest接 188 │ ├── ets 189 │ │ ├── throwerrorability 190 │ │ ├── pages 191 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 192 │ ├── module.json5 193 │ └── resources 194 ├── ohosTest 195 │ ├── ets 196 │ │ ├── test 197 │ │ ├── Ability.test.ets // 自动化测试代码 198throwrangeerror/src/ 199 ├── main 200 │ ├── cpp 201 │ │ ├── types 202 │ │ │ ├── libthrowrangeerror 203 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 204 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 205 │ │ ├── CMakeLists.txt // 配置CMake打包参数 206 │ │ ├── hello.cpp // 实现Native侧的runTest接 207 │ ├── ets 208 │ │ ├── throwrangeerrorability 209 │ │ ├── pages 210 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 211 │ ├── module.json5 212 │ └── resources 213 ├── ohosTest 214 │ ├── ets 215 │ │ ├── test 216 │ │ ├── Ability.test.ets // 自动化测试代码 217throwsyntaxerror/src/ 218 ├── main 219 │ ├── cpp 220 │ │ ├── types 221 │ │ │ ├── libthrowsyntaxerror 222 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 223 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 224 │ │ ├── CMakeLists.txt // 配置CMake打包参数 225 │ │ ├── hello.cpp // 实现Native侧的runTest接 226 │ ├── ets 227 │ │ ├── throwsyntaxerrorability 228 │ │ ├── pages 229 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 230 │ ├── module.json5 231 │ └── resources 232 ├── ohosTest 233 │ ├── ets 234 │ │ ├── test 235 │ │ ├── Ability.test.ets // 自动化测试代码 236throwtypeerror/src/ 237 ├── main 238 │ ├── cpp 239 │ │ ├── types 240 │ │ │ ├── libthrowtypeerror 241 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 242 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 243 │ │ ├── CMakeLists.txt // 配置CMake打包参数 244 │ │ ├── hello.cpp // 实现Native侧的runTest接 245 │ ├── ets 246 │ │ ├── throwtypeerrorability 247 │ │ ├── pages 248 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 249 │ ├── module.json5 250 │ └── resources 251 ├── ohosTest 252 │ ├── ets 253 │ │ ├── test 254 │ │ ├── Ability.test.ets // 自动化测试代码 255``` 256 257### 相关权限 258 259不涉及。 260 261### 依赖 262 263不涉及。 264 265### 约束与限制 266 2671.本示例仅支持标准系统上运行, 支持设备:Phone。 268 2692.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 270 2713.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 272 273### 下载 274 275如需单独下载本工程,执行如下命令: 276 277``` 278git init 279git config core.sparsecheckout true 280echo code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmError > .git/info/sparse-checkout 281git remote add origin https://gitee.com/openharmony/applications_app_samples.git 282git pull origin master 283``` 284