未验证 提交 8ed3a4b3 编写于 作者: O openharmony_ci 提交者: Gitee

!14494 示例代码低错修改

Merge pull request !14494 from zengyawen/master
...@@ -92,6 +92,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo ...@@ -92,6 +92,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo
**示例:** **示例:**
```js ```js
let filePath = pathDir + "/test.txt";
Hash.hash(filePath, "sha256", (err, str) => { Hash.hash(filePath, "sha256", (err, str) => {
if (err) { if (err) {
console.info("calculate file hash failed with error message: " + err.message + ", error code: " + err.code); console.info("calculate file hash failed with error message: " + err.message + ", error code: " + err.code);
......
...@@ -46,11 +46,11 @@ addCheckRule(rule: bigint): void ...@@ -46,11 +46,11 @@ addCheckRule(rule: bigint): void
```js ```js
try { try {
// 添加一条规则 // 添加一条规则
hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);} hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);
// 添加多条规则 // 添加多条规则
hichecker.addCheckRule( // hichecker.addCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
...@@ -76,9 +76,9 @@ try { ...@@ -76,9 +76,9 @@ try {
// 删除一条规则 // 删除一条规则
hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);
// 删除多条规则 // 删除多条规则
hichecker.removeCheckRule( // hichecker.removeCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
...@@ -113,7 +113,7 @@ try { ...@@ -113,7 +113,7 @@ try {
// 查询是否包含 // 查询是否包含
hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true;
hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false; hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false;
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
......
...@@ -297,7 +297,7 @@ import hidebug from '@ohos.hidebug' ...@@ -297,7 +297,7 @@ import hidebug from '@ohos.hidebug'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info(error.code)
...@@ -326,7 +326,7 @@ import hidebug from '@ohos.hidebug' ...@@ -326,7 +326,7 @@ import hidebug from '@ohos.hidebug'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info(error.code)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册