Skip to content

Commit 803e6f4

Browse files
committed
refactor: polish error code documents.
1 parent 09b39e0 commit 803e6f4

File tree

4 files changed

+166
-238
lines changed

4 files changed

+166
-238
lines changed

docs/reference/lang/error/exception.md

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This section mainly includes KCL errors:
3232
| E1003 | [KCLIndentationError](#113-kclindentationerrore1003) | Indentation Error |
3333
| E1I37 | [IllegalArgumentSyntaxError](#114-illegalargumentsyntaxerror-e1i37) | Illegal argument syntax |
3434

35-
### 1.1.1 InvalidSyntaxError (E1001)
35+
### InvalidSyntaxError (E1001)
3636

3737
KCL will report `InvalidSyntaxError` when KCL has a syntax error.
3838

@@ -59,7 +59,7 @@ Possible resolution:
5959

6060
- Check and fix KCL syntax errors based on the KCL Language Standard
6161

62-
### 1.1.2 KCLTabError
62+
### TabError
6363

6464
KCL will report `KCLTabError` when KCL has a tab and white space syntax error.
6565

@@ -89,7 +89,7 @@ Possible resolution:
8989

9090
- Only use a tab or four white spaces in KCL, do not mix them.
9191

92-
### 1.1.3 KCLIndentationError
92+
### IndentationError
9393

9494
KCL will report `KCLIndentationError` when KCL has an indentation syntax error.
9595

@@ -119,7 +119,7 @@ Possible resolution:
119119

120120
- Only use a tab or four white spaces in the KCL program for indentation.
121121

122-
### 1.1.4 IllegalArgumentSyntaxError (E1I37)
122+
### IllegalArgumentSyntaxError (E1I37)
123123

124124
KCL will report `IllegalArgumentSyntaxError` when KCL has an illegal argument in KCL syntax.
125125

@@ -157,7 +157,6 @@ This section mainly includes KCL errors:
157157
| E2F04 | [CannotFindModule](#121-cannotfindmodulee2f04) | Cannot find the module |
158158
| E2F05 | [FailedLoadModule](#122-failedloadmodulee2f05) | Failed to load module |
159159
| E2H13 | [UnKnownDecoratorError](#123-unknowndecoratorerrore2h13) | UnKnown decorator |
160-
| E2H14 | [InvalidDecoratorTargetError](#124-invaliddecoratortargeterrore2h14) | Invalid Decorator Target |
161160
| E2C15 | [MixinNamingError](#125-mixinnamingerrore2c15) | Illegal mixin naming |
162161
| E2C16 | [MixinStructureIllegal](#126-mixinstructureillegale2c16) | Illegal mixin structure |
163162
| E2B17 | [CannotAddMembersComplieError](#127-cannotaddmemberscomplieerrore2b17) | Cannot add members to a schema |
@@ -174,7 +173,7 @@ This section mainly includes KCL errors:
174173
| E2I36 | [IllegalArgumentComplieError](#1218-illegalargumentcomplieerrore2i36) | Illegal argument during compiling |
175174
| E3L41 | [ImmutableCompileError](#1219-immutablecompileerror-e3l41) | Immutable variable is modified |
176175

177-
### 1.2.1 CannotFindModule(E2F04)
176+
### CannotFindModule (E2F04)
178177

179178
KCL will report `CannotFindModule` when KCL imports a module that does not exist.
180179

@@ -203,18 +202,7 @@ Possible resolution:
203202

204203
- Add the import module file under the import path.
205204

206-
### 1.2.2 FailedLoadModule(E2F05)
207-
208-
KCL will report `FailedLoadModule` when an error occurs during loading a KCL external package.
209-
210-
The `ewcode` of `FailedLoadModule` is `E2F05`.
211-
212-
Possible resolution:
213-
214-
- Check whether the module file is readable.
215-
- Check whether the module file is a KCL file.
216-
217-
### 1.2.3 UnKnownDecoratorError(E2H13)
205+
### UnKnownDecoratorError (E2H13)
218206

219207
KCL will report `UnKnownDecoratorError` when an unknown decorator is used in KCL.
220208

@@ -240,7 +228,7 @@ The KCL program will cause the following error message.
240228
error[E2L23]: CompileError
241229
--> deprecated/unknown_fail_1/main.k:1:2
242230
|
243-
1 | @err_deprecated # 这是一个非法的装饰器
231+
1 | @err_deprecated # This is a error decorator
244232
| ^ UnKnown decorator err_deprecated
245233
|
246234
```
@@ -249,17 +237,7 @@ Possible resolution:
249237

250238
- Check whether the decorator exists.
251239

252-
### 1.2.4 InvalidDecoratorTargetError(E2H14)
253-
254-
KCL will report `InvalidDecoratorTargetError` when the target cannot be the target of the decorator.
255-
256-
The `ewcode` of `InvalidDecoratorTargetError` is `E2H14`.
257-
258-
Possible resolution:
259-
260-
- Check whether the decorator in KCL is illegal.
261-
262-
### 1.2.5 MixinNamingError(E2C15)
240+
### MixinNamingError(E2C15)
263241

264242
KCL will report `MixinNamingError` when a mixin name does not end with 'Mixin'.
265243

@@ -302,7 +280,7 @@ Possible resolution:
302280

303281
- If the schema is a mixin, then the name of the schema should end with Mixin.
304282

305-
### 1.2.6 MixinStructureIllegal(E2C16)
283+
### MixinStructureIllegal(E2C16)
306284

307285
KCL will report `MixinStructureIllegal` when the KCL structure is illegal.
308286

@@ -312,7 +290,7 @@ Possible resolution:
312290

313291
- Check the structure of schema as Mixin.
314292

315-
### 1.2.7 CannotAddMembersComplieError(E2B17)
293+
### CannotAddMembersComplieError(E2B17)
316294

317295
KCL will report `CannotAddMembersComplieError` when members that are not in the schema are used.
318296

@@ -361,7 +339,7 @@ Possible resolution:
361339
- Add the members to the schema.
362340
- Remove the using of the members not exists
363341

364-
### 1.2.8 IndexSignatureError(E2B20)
342+
### IndexSignatureError (E2B20)
365343

366344
The `ewcode` of `IndexSignatureError` is `E2B20`.
367345

@@ -482,11 +460,11 @@ Possible resolution:
482460

483461
- Change schema for index signature or change index signature for schema.
484462

485-
### 1.2.9 TypeComplieError(E2G22)
463+
### TypeError (E2G22)
486464

487-
KCL will report `TypeComplieError` when a type error occurs in compiling type check.
465+
KCL will report `TypeError` when a type error occurs in compiling type check.
488466

489-
The `ewcode` of `TypeComplieError` is `E2G22`.
467+
The `ewcode` of `TypeError` is `E2G22`.
490468

491469
For example:
492470

@@ -522,7 +500,7 @@ Possible resolution:
522500

523501
- Check that the type of value assigned to a variable is consistent with the type of the variable.
524502

525-
### 1.2.10 CompileError(E2L23)
503+
### CompileError (E2L23)
526504

527505
The `ewcode` of `CompileError` is `E2L23`.
528506

@@ -672,25 +650,25 @@ error[E2L23]: CompileError
672650
|
673651
```
674652
675-
### 1.2.11 KCLNameError(E2L25)
653+
### NameError (E2L25)
676654
677655
KCL will report `KCLNameError` when a name error occurs in compiling.
678656
679657
The `ewcode` of `KCLNameError` is `E2L25`.
680658
681-
### 1.2.12 KCLValueError(E2L26)
659+
### ValueError (E2L26)
682660
683661
KCL will report `KCLValueError` will be raised when a value error occurs in compiling.
684662
685663
The `ewcode` of `KCLValueError` is `E2L25`.
686664
687-
### 1.2.13 KCLKeyError(E2L27)
665+
### KeyError (E2L27)
688666
689667
KCL will report `KCLKeyError` will be raised when a key error occurs in compiling.
690668
691669
The `ewcode` of `KCLKeyError` is `E2L25`.
692670
693-
### 1.2.14 UniqueKeyError(E2L28)
671+
### UniqueKeyError (E2L28)
694672
695673
KCL will report `UniqueKeyError` when duplicate names appear in the KCL code.
696674
@@ -731,7 +709,7 @@ Possible resolution:
731709
732710
- Check if the name with error has been used.
733711
734-
### 1.2.15 KCLAttributeComplieError(E2A29)
712+
### AttributeComplieError (E2A29)
735713
736714
KCL will report `KCLAttributeComplieError` when KCL has an illegal attribute in the schema.
737715
@@ -765,7 +743,7 @@ Possible resolution:
765743
766744
- Check for the existence of the schema attribute when using it.
767745
768-
### 1.2.16 MultiInheritError(E2D32)
746+
### MultiInheritError (E2D32)
769747
770748
KCL will report `MultiInheritError` when multiple inheritance appears in the schema.
771749
@@ -801,7 +779,7 @@ Possible resolution:
801779
802780
- Check the inheritance structure of the program, and multi-inheritance is not supported in KCL.
803781
804-
### 1.2.17 IllegalInheritError(E2D34)
782+
### IllegalInheritError (E2D34)
805783
806784
KCL will report `IllegalInheritError` when an illegal inheritance occurs in the schema.
807785
@@ -832,11 +810,12 @@ Possible resolution:
832810
833811
- Schema supports single inheritance of schema in KCL.
834812
835-
### 1.2.18 IllegalArgumentComplieError(E2I36)
813+
### IllegalArgumentComplieError (E2I36)
836814
837815
KCL will report `IllegalArgumentComplieError` when the argument of option in KCL is illegal.
838816
839817
The `ewcode` of `IllegalArgumentComplieError` is `E2I36`.
818+
840819
For example:
841820
842821
```python
@@ -857,7 +836,7 @@ Possible resolution:
857836
858837
- Check whether the KCL option arguments are legal.
859838
860-
### 1.2.19 ImmutableCompileError (E3L41)
839+
### ImmutableCompileError (E3L41)
861840
862841
KCL will report `ImmutableCompileError` when the value of the immutable variable changes.
863842
@@ -913,7 +892,7 @@ This section mainly includes KCL errors:
913892
| E2D33 | [CycleInheritError](#1313-cycleinheriterror-e2d33) | Cycle Inheritance is illegal |
914893
| E3M42 | [KCLRecursionError](#1314-kclrecursionerror-e3m42) | Recursively reference |
915894
916-
### 1.3.1 RecursiveLoad (E3F06)
895+
### RecursiveLoad (E3F06)
917896
918897
KCL will report `RecursiveLoad` when a cycle import of external packages occurs in KCL.
919898
@@ -948,7 +927,7 @@ Possible resolution:
948927
949928
- Check whether there is a circle import in KCL.
950929
951-
### 1.3.2 FloatOverflow (E3K04)
930+
### FloatOverflow (E3K04)
952931
953932
KCL will report `FloatOverflow` when a floating-point number overflows in KCL.
954933
@@ -979,7 +958,7 @@ Possible resolution:
979958
980959
- Check whether the value of the float is the float range supported by KCL.
981960
982-
### 1.3.3 IntOverflow (E3K09)
961+
### IntOverflow (E3K09)
983962
984963
KCL will report `IntOverflow` when an integer number overflows in KCL.
985964
@@ -1009,7 +988,7 @@ Possible resolution:
1009988
1010989
- Check whether the value of the integer is the integer range supported by KCL.
1011990
1012-
### 1.3.4 DeprecatedError (E3N11)
991+
### DeprecatedError (E3N11)
1013992
1014993
KCL will report `DeprecatedError` when a deprecated variable is used and the strict is True.
1015994
@@ -1046,7 +1025,7 @@ Possible resolution:
10461025
- You can set the strict to False which will cause a warning insteads of an error.
10471026
- Adjust the code without using deprecated code.
10481027
1049-
### 1.3.5 KCLAttributeRuntimeError (E3A30)
1028+
### AttributeRuntimeError (E3A30)
10501029
10511030
KCL will report `KCLAttributeRuntimeError`, if an error occurs during dynamically accessing schema attributes through variables at runtime.
10521031
@@ -1075,7 +1054,7 @@ Possible resolution:
10751054
10761055
- Check whether the attributes of schema are correct.
10771056
1078-
### 1.3.6 TypeRuntimeError (E3G21)
1057+
### TypeRuntimeError (E3G21)
10791058
10801059
KCL will report `TypeRuntimeError` when an type error occurs in the runtime type check.
10811060
@@ -1107,7 +1086,7 @@ Possible resolution:
11071086
11081087
- Stop the wrong type union or adjust to the type union supported by KCL.
11091088
1110-
### 1.3.7 SchemaCheckFailure (E3B17)
1089+
### SchemaCheckFailure (E3B17)
11111090
11121091
KCL will report `SchemaCheckFailure` when the schema check conditions are not met.
11131092
@@ -1149,7 +1128,7 @@ Possible resolution:
11491128
11501129
- Check whether the attributes of schema can satisfy the conditions in check.
11511130
1152-
### 1.3.8 CannotAddMembersRuntimeError(E3B19)
1131+
### CannotAddMembersRuntimeError (E3B19)
11531132
11541133
KCL will report `CannotAddMembersRuntimeError` when members that are not in the schema are used.
11551134
@@ -1185,7 +1164,7 @@ Possible resolution:
11851164
- Add a non-existent member to the schema.
11861165
- Access members that exist in the schema.
11871166
1188-
### 1.3.9 EvaluationError(E3M38)
1167+
### EvaluationError (E3M38)
11891168
11901169
KCL will report `EvaluationError` when an illegal evaluation occurs in KCL.
11911170
@@ -1215,7 +1194,7 @@ Possible resolution:
12151194
12161195
- Check whether the evaluation of the expression is legal.
12171196
1218-
### 1.3.10 InvalidFormatSpec (E3M39)
1197+
### InvalidFormatSpec (E3M39)
12191198
12201199
KCL will report `InvalidFormatSpec` when an illegal string format appears in KCL.
12211200
@@ -1244,11 +1223,11 @@ Possible resolution:
12441223
12451224
- Adjust illegal String to String supported by KCL standards.
12461225
1247-
### 1.3.11 KCLAssertionError (E3M40)
1226+
### AssertionError (E3M40)
12481227
1249-
KCL will report `KCLAssertionError` when assert False occurs in KCL.
1228+
KCL will report `AssertionError` when assert False occurs in KCL.
12501229
1251-
The `ewcode` of `KCLAssertionError` is `E3M40`.
1230+
The `ewcode` of `AssertionError` is `E3M40`.
12521231
12531232
For example:
12541233
@@ -1271,7 +1250,7 @@ Possible resolution:
12711250
12721251
- Check the condition of Assert, and when the Assert condition is False, such an error occurs, removing the Assert statement or changing the condition to True.
12731252
1274-
### 1.3.12 ImmutableRuntimeError (E3M44)
1253+
### ImmutableRuntimeError (E3M44)
12751254
12761255
KCL will report `ImmutableRuntimeError` when the value of the immutable variable changes.
12771256
@@ -1307,7 +1286,7 @@ Possible resolution:
13071286
13081287
- Check if the final variables have been assigned or other changes affect the values of the final variables.
13091288
1310-
### 1.3.13 CycleInheritError (E2D33)
1289+
### CycleInheritError (E2D33)
13111290
13121291
KCL will report `CycleInheritError` when circle inheritance appeared in the schema.
13131292
@@ -1345,7 +1324,7 @@ Possible resolution:
13451324
13461325
- Check schema inheritance relationship to avoid A inheritance B and B inheritance A at the same time.
13471326
1348-
### 1.3.14 KCLRecursionError (E3M42)
1327+
### RecursionError (E3M42)
13491328
13501329
KCL will report `KCLRecursionError` when a circle reference appears in the program.
13511330
@@ -1396,7 +1375,7 @@ This section mainly includes KCL warnings:
13961375
| W2P10 | [InvalidDocstring](#142-invaliddocstring-w2p10) | Invalid docstring |
13971376
| W2N12 | [DeprecatedWarning](#143-deprecatedwarning-w2n12) | Deprecated warning |
13981377
1399-
### 1.4.1 FloatUnderflow (W2K04)
1378+
### FloatUnderflow (W2K04)
14001379
14011380
KCL will report `FloatUnderflow` when a floating-point number underflows in KCL.
14021381
@@ -1406,7 +1385,7 @@ Possible resolution:
14061385
14071386
- Check whether the value of the float number is in the range supported by KCL.
14081387
1409-
### 1.4.2 InvalidDocstring (W2P10)
1388+
### InvalidDocstring (W2P10)
14101389
14111390
KCL will report `InvalidDocstring` when a string is illegal in KCL doc.
14121391
@@ -1416,7 +1395,7 @@ Possible resolution:
14161395
14171396
- Please write doc according to KCL standards.
14181397
1419-
### 1.4.3 DeprecatedWarning (W2N12)
1398+
### DeprecatedWarning (W2N12)
14201399
14211400
KCL will report `DeprecatedWarning` when a deprecated variable is used and the strict is False.
14221401

0 commit comments

Comments
 (0)