1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <iostream>
17
18 #include "restool_errors.h"
19
20 namespace OHOS {
21 namespace Global {
22 namespace Restool {
23 const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
24 // 11200000
25 { ERR_CODE_UNDEFINED_ERROR,
26 { ERR_CODE_UNDEFINED_ERROR, "Undefined Error", "Unknown error: %s", "", { "Please try again." }, {} } },
27
28 // 11201xxx
29 { ERR_CODE_LOAD_LIBRARY_FAIL,
30 { ERR_CODE_LOAD_LIBRARY_FAIL,
31 ERR_TYPE_DEPENDENCY,
32 "Failed to load the library '%s', %s",
33 "",
34 { "Make sure the library path is correct and has access permissions.",
35 "Install the missing third-party dependency libraries displayed in the error information.",
36 "Adding the path 'openharmony\\previewer\\common\\bin' in your SDK path to environment variables." },
37 {} } },
38
39 // 11203xxx
40 { ERR_CODE_OPEN_JSON_FAIL,
41 { ERR_CODE_OPEN_JSON_FAIL,
42 ERR_TYPE_CONFIG,
43 "Failed to open the JSON file '%s', %s.",
44 "",
45 { "Make sure the JSON file path is correct and has access permissions." },
46 {} } },
47 { ERR_CODE_JSON_FORMAT_ERROR,
48 { ERR_CODE_JSON_FORMAT_ERROR,
49 ERR_TYPE_CONFIG,
50 "Failed to parse the JSON file, format is incorrect.",
51 "",
52 { "Check the JSON file and delete unnecessary commas (,).",
53 "Check the JSON file to make sure the root bracket is {}." },
54 {} } },
55 { ERR_CODE_JSON_NODE_MISMATCH,
56 { ERR_CODE_JSON_NODE_MISMATCH,
57 ERR_TYPE_CONFIG,
58 "The value type of node '%s' does not match, expected type: %s.",
59 "",
60 {},
61 {} } },
62 { ERR_CODE_JSON_NODE_MISSING,
63 { ERR_CODE_JSON_NODE_MISSING, ERR_TYPE_CONFIG, "The required node '%s' is missing.", "", {}, {} } },
64 { ERR_CODE_JSON_NODE_EMPTY,
65 { ERR_CODE_JSON_NODE_EMPTY, ERR_TYPE_CONFIG, "The array or object node '%s' cannot be empty.", "", {}, {} } },
66 { ERR_CODE_JSON_NOT_ONE_MEMBER,
67 { ERR_CODE_JSON_NOT_ONE_MEMBER,
68 ERR_TYPE_CONFIG,
69 "The node '%s' of the JSON file can only have one member.",
70 "",
71 {},
72 {} } },
73 { ERR_CODE_JSON_INVALID_NODE_NAME,
74 { ERR_CODE_JSON_INVALID_NODE_NAME,
75 ERR_TYPE_CONFIG,
76 "Invalid node name '%s', it should be one of %s.",
77 "",
78 {},
79 {} } },
80
81 // 11204xxx
82 { ERR_CODE_CREATE_FILE_ERROR,
83 { ERR_CODE_CREATE_FILE_ERROR,
84 ERR_TYPE_FILE_RESOURCE,
85 "Failed to create directory or file '%s', %s.",
86 "",
87 { "Make sure the file path is correct and has access permissions." },
88 {} } },
89 { ERR_CODE_REMOVE_FILE_ERROR,
90 { ERR_CODE_REMOVE_FILE_ERROR,
91 ERR_TYPE_FILE_RESOURCE,
92 "Failed to delete directory or file '%s', %s.",
93 "",
94 { "Make sure the file path is correct and has access permissions." },
95 {} } },
96 { ERR_CODE_COPY_FILE_ERROR,
97 { ERR_CODE_COPY_FILE_ERROR,
98 ERR_TYPE_FILE_RESOURCE,
99 "Failed to copy file from '%s' to '%s', %s.",
100 "",
101 { "Make sure the src and dest file path is correct and has access permissions." },
102 {} } },
103 { ERR_CODE_OPEN_FILE_ERROR,
104 { ERR_CODE_OPEN_FILE_ERROR,
105 ERR_TYPE_FILE_RESOURCE,
106 "Failed to open file '%s', %s.",
107 "",
108 { "Make sure the file path is correct and has access permissions." },
109 {} } },
110 { ERR_CODE_READ_FILE_ERROR,
111 { ERR_CODE_READ_FILE_ERROR,
112 ERR_TYPE_FILE_RESOURCE,
113 "Failed to read file '%s', %s.",
114 "",
115 { "Make sure the file content is correct." },
116 {} } },
117
118 // 11210xxx
119 { ERR_CODE_UNKNOWN_COMMAND_ERROR,
120 { ERR_CODE_UNKNOWN_COMMAND_ERROR,
121 ERR_TYPE_COMMAND_PARSE,
122 "Unknown command error: %s",
123 "",
124 { "For details, see the help with option -h/--help." },
125 {} } },
126 { ERR_CODE_UNKNOWN_OPTION,
127 { ERR_CODE_UNKNOWN_OPTION,
128 ERR_TYPE_COMMAND_PARSE,
129 "Unknown option '%s'.",
130 "",
131 { "For details, see the help with option -h/--help." },
132 {} } },
133 { ERR_CODE_MISSING_ARGUMENT,
134 { ERR_CODE_MISSING_ARGUMENT,
135 ERR_TYPE_COMMAND_PARSE,
136 "Option '%s' should have a argument.",
137 "",
138 { "For details, see the help with option -h/--help." },
139 {} } },
140 { ERR_CODE_INVALID_ARGUMENT,
141 { ERR_CODE_INVALID_ARGUMENT,
142 ERR_TYPE_COMMAND_PARSE,
143 "Invalid argument value '%s'.",
144 "",
145 { "For details, see the help with option -h/--help." },
146 {} } },
147 { ERR_CODE_INVALID_INPUT,
148 { ERR_CODE_INVALID_INPUT,
149 ERR_TYPE_COMMAND_PARSE,
150 "Invalid input path '%s'.",
151 "",
152 { "Make sure the input path of option -i/--inputPath is correct." },
153 {} } },
154 { ERR_CODE_DUPLICATE_INPUT,
155 { ERR_CODE_DUPLICATE_INPUT,
156 ERR_TYPE_COMMAND_PARSE,
157 "Duplicated input path '%s'.",
158 "",
159 { "Make sure the input path of option -i/--inputPath is unique." },
160 {} } },
161 { ERR_CODE_DOUBLE_PACKAGE_NAME,
162 { ERR_CODE_DOUBLE_PACKAGE_NAME,
163 ERR_TYPE_COMMAND_PARSE,
164 "The package name '%s' and '%s' conflict.",
165 "",
166 { "Make sure the option -p/--packageName only specified once." },
167 {} } },
168 { ERR_CODE_INVALID_OUTPUT,
169 { ERR_CODE_INVALID_OUTPUT,
170 ERR_TYPE_COMMAND_PARSE,
171 "Invalid output path '%s'.",
172 "",
173 { "Make sure the output path of option -o/--outputPath is correct." },
174 {} } },
175 { ERR_CODE_DOUBLE_OUTPUT,
176 { ERR_CODE_DOUBLE_OUTPUT,
177 ERR_TYPE_COMMAND_PARSE,
178 "The output path '%s' and '%s' conflict.",
179 "",
180 { "Make sure the option -o/--outputPath only specified once." },
181 {} } },
182 { ERR_CODE_DUPLICATE_RES_HEADER,
183 { ERR_CODE_DUPLICATE_RES_HEADER,
184 ERR_TYPE_COMMAND_PARSE,
185 "Duplicated res header path '%s'.",
186 "",
187 { "Make sure the path of option -r/--resHeader is unique." },
188 {} } },
189 { ERR_CODE_DOUBLE_MODULES,
190 { ERR_CODE_DOUBLE_MODULES,
191 ERR_TYPE_COMMAND_PARSE,
192 "The module name '%s' and '%s' conflict.",
193 "",
194 { "Make sure the option -m/--modules only specified once." },
195 {} } },
196 { ERR_CODE_DUPLICATE_MODULE_NAME,
197 { ERR_CODE_DUPLICATE_MODULE_NAME,
198 ERR_TYPE_COMMAND_PARSE,
199 "Duplicated module name '%s'.",
200 "",
201 { "Make sure the module names specified with option -m/--modules is unique." },
202 {} } },
203 { ERR_CODE_DOUBLE_CONFIG_JSON,
204 { ERR_CODE_DOUBLE_CONFIG_JSON,
205 ERR_TYPE_COMMAND_PARSE,
206 "The module.json(in Stage Model) or config.json(in FA Model) path '%s' and '%s' conflict.",
207 "",
208 { "Make sure the option -j/--json only specified once." },
209 {} } },
210 { ERR_CODE_INVALID_START_ID,
211 { ERR_CODE_INVALID_START_ID,
212 ERR_TYPE_COMMAND_PARSE,
213 "Invalid start id '%s', out of range.",
214 "",
215 { "Make sure the start id in the scope [0x01000000, 0x06FFFFFF) or [0x08000000, 0xFFFFFFFF)." },
216 {} } },
217 { ERR_CODE_DUPLICATE_APPEND_PATH,
218 { ERR_CODE_DUPLICATE_APPEND_PATH,
219 ERR_TYPE_COMMAND_PARSE,
220 "Duplicated append path '%s'.",
221 "",
222 { "Make sure the path of option -x/--append is unique." },
223 {} } },
224 { ERR_CODE_DOUBLE_TARGET_CONFIG,
225 { ERR_CODE_DOUBLE_TARGET_CONFIG,
226 ERR_TYPE_COMMAND_PARSE,
227 "The target config '%s' and '%s' conflict.",
228 "",
229 { "Make sure the option --target-config only specified once." },
230 {} } },
231 { ERR_CODE_INVALID_TARGET_CONFIG,
232 { ERR_CODE_INVALID_TARGET_CONFIG,
233 ERR_TYPE_COMMAND_PARSE,
234 "Invalid target config argument '%s'.The argument format of option --target-config is supposed to be like "
235 "'Locale[zh_CN,en_US];Device[phone]'.",
236 "",
237 { "For more information, see the developer documentation." },
238 {} } },
239 { ERR_CODE_INVALID_SYSTEM_ID_DEFINED,
240 { ERR_CODE_INVALID_SYSTEM_ID_DEFINED,
241 ERR_TYPE_COMMAND_PARSE,
242 "Invalid system id_defined.json path '%s'.",
243 "",
244 { "Make sure the system id_defined.json path is correct." },
245 {} } },
246 { ERR_CODE_DUPLICATE_SYSTEM_ID_DEFINED,
247 { ERR_CODE_DUPLICATE_SYSTEM_ID_DEFINED,
248 ERR_TYPE_COMMAND_PARSE,
249 "Duplicated system id_defined.json path '%s'.",
250 "",
251 { "Make sure the system id_defined.json path is unique." },
252 {} } },
253 { ERR_CODE_DOUBLE_COMPRESSION_PATH,
254 { ERR_CODE_DOUBLE_COMPRESSION_PATH,
255 ERR_TYPE_COMMAND_PARSE,
256 "The compression JSON path '%s' and '%s' conflict.",
257 "",
258 { "Make sure the option --compressed-config only specified once." },
259 {} } },
260 { ERR_CODE_NON_ASCII,
261 { ERR_CODE_NON_ASCII,
262 ERR_TYPE_COMMAND_PARSE,
263 "The argument value '%s' is not an ASCII value.",
264 "",
265 { "Make sure all the arguments value characters is ASCII." },
266 {} } },
267 { ERR_CODE_EXCLUSIVE_OPTION,
268 { ERR_CODE_EXCLUSIVE_OPTION,
269 ERR_TYPE_COMMAND_PARSE,
270 "Option '%s' and '%s' cannot be used together.",
271 "",
272 {},
273 {} } },
274 { ERR_CODE_PACKAGE_NAME_EMPTY,
275 { ERR_CODE_PACKAGE_NAME_EMPTY,
276 ERR_TYPE_COMMAND_PARSE,
277 "The package name is empty, it should be specified with option -p/--packageName",
278 "",
279 { "Specifies the package name with option -p/--packageName." },
280 {} } },
281 { ERR_CODE_RES_HEADER_PATH_EMPTY,
282 { ERR_CODE_RES_HEADER_PATH_EMPTY,
283 ERR_TYPE_COMMAND_PARSE,
284 "The resource header path(like ./ResourceTable.js, ./ResrouceTable.h) is empty, it should be specified with "
285 "option -r/--resHeader.",
286 "",
287 { "Specifies header path with option -r/--resHeader." },
288 {} } },
289 { ERR_CODE_DUMP_MISSING_INPUT,
290 { ERR_CODE_DUMP_MISSING_INPUT,
291 ERR_TYPE_COMMAND_PARSE,
292 "The HAP path of the resource dump command is missing.",
293 "",
294 { "Specifies a HAP path with dump command." },
295 {} } },
296 { ERR_CODE_DUMP_INVALID_INPUT,
297 { ERR_CODE_DUMP_INVALID_INPUT,
298 ERR_TYPE_COMMAND_PARSE,
299 "Invalid HAP path '%s' of the resource dump command.",
300 "",
301 { "Make sure the HAP path of dump command is correct." },
302 {} } },
303 { ERR_CODE_INVALID_THREAD_COUNT,
304 { ERR_CODE_INVALID_THREAD_COUNT,
305 ERR_TYPE_COMMAND_PARSE,
306 "Invalid thread count '%s', it should be an integer and greater than 0.",
307 "",
308 {},
309 {} } },
310
311 // 11211xxx
312 { ERR_CODE_OUTPUT_EXIST,
313 { ERR_CODE_OUTPUT_EXIST,
314 ERR_TYPE_RESOURCE_PACK,
315 "Output path exists, but option -f/--forceWrite not specified.",
316 "",
317 { "Remove the exist output dir or use option -f to force write." },
318 {} } },
319 { ERR_CODE_CONFIG_JSON_MISSING,
320 { ERR_CODE_CONFIG_JSON_MISSING,
321 ERR_TYPE_RESOURCE_PACK,
322 "Multiple input paths, but the module.json(in Stage Model) or config.json(in FA Model) path is not specified "
323 "with option -j/--json.",
324 "",
325 { "Specifies option -j/--json." },
326 {} } },
327 { ERR_CODE_INVALID_MODULE_TYPE,
328 { ERR_CODE_INVALID_MODULE_TYPE,
329 ERR_TYPE_RESOURCE_PACK,
330 "Invalid module type '%s', it should be one of [\"entry\", \"har\", \"shared\", \"feature\"].",
331 "",
332 {},
333 {} } },
334 { ERR_CODE_EXCLUSIVE_START_ID,
335 { ERR_CODE_EXCLUSIVE_START_ID,
336 ERR_TYPE_RESOURCE_PACK,
337 "The id_defined.json and the start id '%lu' specified with option -e/--startId conflict.",
338 "",
339 { "Retain only one of the id_defined.json and the start id." },
340 {} } },
341 { ERR_CODE_ID_DEFINED_INVALID_TYPE,
342 { ERR_CODE_ID_DEFINED_INVALID_TYPE,
343 ERR_TYPE_RESOURCE_PACK,
344 "Invalid resource type '%s' in the id_defined.json, it should be one of %s.",
345 "",
346 {},
347 {} } },
348 { ERR_CODE_ID_DEFINED_INVALID_ID,
349 { ERR_CODE_ID_DEFINED_INVALID_ID,
350 ERR_TYPE_RESOURCE_PACK,
351 "Invalid id value '%s' in the id_defined.json, it shoud be a hex string, match the pattern "
352 "^0[xX][0-9a-fA-F]{8}, and in the scope [0x01000000,0x06FFFFFF] or [0x08000000,0xFFFFFFFF].",
353 "",
354 {},
355 {} } },
356 { ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
357 { ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
358 ERR_TYPE_RESOURCE_PACK,
359 "The order value '%lu' in the id_defined.json does not match the record element sequence '%lu', "
360 "expected value: %lu.",
361 "",
362 { "Make sure the order value is same as the sequence." },
363 {} } },
364 { ERR_CODE_ID_DEFINED_SAME_ID,
365 { ERR_CODE_ID_DEFINED_SAME_ID,
366 ERR_TYPE_RESOURCE_PACK,
367 "The name '%s' and '%s' in the id_defined.json define the same ID.",
368 "",
369 {},
370 {} } },
371 { ERR_CODE_MODULE_NAME_NOT_FOUND,
372 { ERR_CODE_MODULE_NAME_NOT_FOUND,
373 ERR_TYPE_RESOURCE_PACK,
374 "The module name '%s' not found in %s, which specifies with -m/--modules.",
375 "",
376 { "Make sure the module name in module.json(in Stage Model) or config.json(in FA Model) is correct." },
377 {} } },
378 { ERR_CODE_INVALID_RESOURCE_PATH,
379 { ERR_CODE_INVALID_RESOURCE_PATH,
380 ERR_TYPE_RESOURCE_PACK,
381 "Failed to scan resources, invalid path '%s', %s.",
382 "",
383 {},
384 {} } },
385 { ERR_CODE_INVALID_LIMIT_KEY,
386 { ERR_CODE_INVALID_LIMIT_KEY,
387 ERR_TYPE_RESOURCE_PACK,
388 "Invalid qualifiers key '%s', it should match the pattern of qualifiers directory,for example zh_CN,en_US,etc.",
389 "",
390 { "For more information, see the developer documentation." },
391 {} } },
392 { ERR_CODE_INVALID_RESOURCE_DIR,
393 { ERR_CODE_INVALID_RESOURCE_DIR,
394 ERR_TYPE_RESOURCE_PACK,
395 "Invalid resource directory name '%s', it should be one of %s.",
396 "",
397 {},
398 {} } },
399 { ERR_CODE_INVALID_TRANSLATE_PRIORITY,
400 { ERR_CODE_INVALID_TRANSLATE_PRIORITY,
401 ERR_TYPE_RESOURCE_PACK,
402 "Invalid translate priority value '%s', it should be one of %s.",
403 "",
404 {},
405 {} } },
406 { ERR_CODE_INVALID_ELEMENT_TYPE,
407 { ERR_CODE_INVALID_ELEMENT_TYPE,
408 ERR_TYPE_RESOURCE_PACK,
409 "Unsupported element resource type '%s', it should be one of %s.",
410 "",
411 {},
412 {} } },
413 { ERR_CODE_INVALID_COLOR_VALUE,
414 { ERR_CODE_INVALID_COLOR_VALUE,
415 ERR_TYPE_RESOURCE_PACK,
416 "Invalid color value '%s' of the resource '%s', it only supported reference '$color:xxx' or '#rgb','#argb',"
417 "'#rrggbb','#aarrggbb'.",
418 "",
419 {},
420 {} } },
421 { ERR_CODE_INVALID_RESOURCE_REF,
422 { ERR_CODE_INVALID_RESOURCE_REF,
423 ERR_TYPE_RESOURCE_PACK,
424 "Invalid resource reference '%s', it only supported reference '%sxxx'.",
425 "",
426 {},
427 {} } },
428 { ERR_CODE_PARENT_EMPTY,
429 { ERR_CODE_PARENT_EMPTY,
430 ERR_TYPE_RESOURCE_PACK,
431 "The parent value of resource '%s' is empty, it should be a valid resource name.",
432 "",
433 {},
434 {} } },
435 { ERR_CODE_ARRAY_TOO_LARGE,
436 { ERR_CODE_ARRAY_TOO_LARGE,
437 ERR_TYPE_RESOURCE_PACK,
438 "The array resource '%s' is to large, the total length of the value of the array elements cannot exceed 65535.",
439 "",
440 { "Separate the large array into multiple arrays." },
441 {} } },
442 { ERR_CODE_INVALID_QUANTITY,
443 { ERR_CODE_INVALID_QUANTITY,
444 ERR_TYPE_RESOURCE_PACK,
445 "Invalid quantity '%s' of the resource '%s', it should be one of %s.",
446 "",
447 {},
448 {} } },
449 { ERR_CODE_DUPLICATE_QUANTITY,
450 { ERR_CODE_DUPLICATE_QUANTITY,
451 ERR_TYPE_RESOURCE_PACK,
452 "Duplicated quantity '%s' of the plural resource '%s'.",
453 "",
454 { "Make sure the quantity of the plural resource is unique." },
455 {} } },
456 { ERR_CODE_QUANTITY_NO_OTHER,
457 { ERR_CODE_QUANTITY_NO_OTHER,
458 ERR_TYPE_RESOURCE_PACK,
459 "The plural resource '%s' should contains 'other' quantity.",
460 "",
461 {},
462 {} } },
463 { ERR_CODE_INVALID_SYMBOL,
464 { ERR_CODE_INVALID_SYMBOL,
465 ERR_TYPE_RESOURCE_PACK,
466 "Invalid value '%d' of the symbol resource '%s', it should be in the scope [0xF0000,0xFFFFF] or "
467 "[0x100000,0x10FFFF].",
468 "",
469 {},
470 {} } },
471 { ERR_CODE_INVALID_RESOURCE_NAME,
472 { ERR_CODE_INVALID_RESOURCE_NAME,
473 ERR_TYPE_RESOURCE_PACK,
474 "Invalid resource name '%s', it should be match the pattern [a-zA-Z0-9_].",
475 "",
476 { "Modify the name to match the pattern [a-zA-Z0-9_]." },
477 {} } },
478 { ERR_CODE_RESOURCE_DUPLICATE,
479 { ERR_CODE_RESOURCE_DUPLICATE,
480 ERR_TYPE_RESOURCE_PACK,
481 "Resource '%s' conflict, first declared at '%s', but declare again at '%s'.",
482 "",
483 { "Make sure the resource name of the same type is unique." },
484 {} } },
485 { ERR_CODE_RESOURCE_ID_EXCEED,
486 { ERR_CODE_RESOURCE_ID_EXCEED,
487 ERR_TYPE_RESOURCE_PACK,
488 "The resource id '%lu' exceed, greater than the max id '%lu'.",
489 "",
490 { "Delete useless resources and recompile.", "Specify a smaller start id." },
491 {} } },
492 { ERR_CODE_RESOURCE_ID_NOT_DEFINED,
493 { ERR_CODE_RESOURCE_ID_NOT_DEFINED,
494 ERR_TYPE_RESOURCE_PACK,
495 "The id of resource '%s' of the '%s' type is not defined.",
496 "",
497 { "Delete useless resources and recompile." },
498 {} } },
499 { ERR_CODE_REF_NOT_DEFINED,
500 { ERR_CODE_REF_NOT_DEFINED,
501 ERR_TYPE_RESOURCE_PACK,
502 "The resource reference '%s' is not defined.",
503 "",
504 { "Check whether this resource is defined anywhere." },
505 {} } },
506 { ERR_CODE_INVALID_RESOURCE_INDEX,
507 { ERR_CODE_INVALID_RESOURCE_INDEX,
508 ERR_TYPE_RESOURCE_PACK,
509 "Failed to parse the resources.index file, %s.",
510 "",
511 { "Verify that the format of the resource.index file is correct." },
512 {} } },
513
514 // 11212xxx
515 { ERR_CODE_PARSE_HAP_ERROR,
516 { ERR_CODE_PARSE_HAP_ERROR, ERR_TYPE_RESOURCE_DUMP, "Failed to parse the hap, %s.", "", {}, {} } },
517 };
518
GetError(const uint32_t & errCode)519 ErrorInfo GetError(const uint32_t &errCode)
520 {
521 ErrorInfo error;
522 if (ERRORS_MAP.count(errCode) == 0) {
523 return error;
524 }
525 auto it = ERRORS_MAP.find(errCode);
526 if (it != ERRORS_MAP.end()) {
527 return it->second;
528 }
529 return error;
530 }
531
PrintError(const uint32_t & errCode)532 void PrintError(const uint32_t &errCode)
533 {
534 PrintError(GetError(errCode));
535 }
536
PrintError(const ErrorInfo & error)537 void PrintError(const ErrorInfo &error)
538 {
539 std::string errMsg;
540 errMsg.append("Error Code: ").append(std::to_string(error.code_)).append("\n");
541 errMsg.append("Error: ").append(error.description_).append("\n");
542 errMsg.append("Error Message: ").append(error.cause_);
543 if (!error.position_.empty()) {
544 errMsg.append(" At file: ").append(error.position_);
545 }
546 errMsg.append("\n");
547 if (!error.solutions_.empty()) {
548 errMsg.append("* Try the following:").append("\n");
549 for (const auto &solution : error.solutions_) { errMsg.append(" > ").append(solution).append("\n"); }
550 if (!error.moreInfo_.cn.empty()) {
551 errMsg.append("> More info: ").append(error.moreInfo_.cn).append("\n");
552 }
553 }
554 std::cerr << errMsg;
555 }
556 } // namespace Restool
557 } // namespace Global
558 } // namespace OHOS
559