1/* 2 * Copyright (c) 2024 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 16export const ERROR_DESCRIPTION = 'ArkTS Compiler Error'; 17export const ARKUI_SUBSYSTEM_CODE = '109'; // ArkUI subsystem coding 18export const LINTER_SUBSYSTEM_CODE = '106'; // Linter subsystem coding 19export const ERROR_TYPE_CODE = '05'; // Error Type Code 20export const EXTENSION_CODE = '999'; // Extended Codes Defined by Various Subsystems 21 22interface MoreInfo { 23 cn: string; 24 en: string; 25} 26 27export interface HvigorLogInfo { 28 code?: string; 29 description?: string; 30 cause?: string; 31 position?: string; 32 solutions?: string[]; 33 moreInfo?: MoreInfo; 34} 35 36export class HvigorErrorInfo implements HvigorLogInfo { 37 code: string = ''; 38 description: string = ERROR_DESCRIPTION; 39 cause: string = ''; 40 position: string = ''; 41 solutions: string[] = []; 42 43 getCode(): string { 44 return this.code; 45 } 46 47 setCode(code: string): HvigorErrorInfo { 48 this.code = code; 49 return this; 50 } 51 52 getDescription(): string { 53 return this.description; 54 } 55 56 setDescription(description: string): HvigorErrorInfo { 57 this.description = description; 58 return this; 59 } 60 61 getCause(): string { 62 return this.cause; 63 } 64 65 setCause(cause: string): HvigorErrorInfo { 66 this.cause = cause; 67 return this; 68 } 69 70 getPosition(): string { 71 return this.position; 72 } 73 74 setPosition(position: string): HvigorErrorInfo { 75 this.position = position; 76 return this; 77 } 78 79 getSolutions(): string[] { 80 return this.solutions; 81 } 82 83 setSolutions(solutions: string[]): HvigorErrorInfo { 84 this.solutions = solutions; 85 return this; 86 } 87} 88