Skip to content

Commit 040b0c7

Browse files
committed
Add as_text to the doc
1 parent 000a4ca commit 040b0c7

10 files changed

+118
-86
lines changed

doc/files/JSON-CONFIG-FILE.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,18 @@ Returned errors:
7070
{
7171
"error": JSONProperty.Errors.WRONG_TYPE,
7272
"expected": JSONProperty.Types.INTEGER,
73-
"context": "age"
73+
"context": "age",
74+
"as_text": "Wrong type: expected 'integer', at 'age'."
7475
},
7576
{
7677
"error": JSONProperty.Errors.OBJECT_NON_VALID_PROPERTY,
77-
"property": "unrequired_property"
78+
"property": "unrequired_property",
79+
"as_text": "The property 'unrequired_property' is not a valid one."
7880
},
7981
{
8082
"error": JSONProperty.Errors.OBJECT_MISSING_PROPERTY,
81-
"property": "name"
83+
"property": "name",
84+
"as_text": "The property 'name' has not been specified."
8285
}
8386
]
8487
```
@@ -136,7 +139,8 @@ Returned error:
136139
[
137140
{
138141
"error": JSONProperty.Errors.OBJECT_ONE_IS_REQUIRED,
139-
"properties": ["student", "employee"]
142+
"properties": ["student", "employee"],
143+
"as_text": "One of this properties needs to be specified: student, employee."
140144
}
141145
]
142146
```
@@ -160,7 +164,8 @@ Returned error:
160164
[
161165
{
162166
"error": JSONProperty.Errors.OBJECT_EXCLUSIVITY_ERROR,
163-
"properties": ["student", "employee"]
167+
"properties": ["student", "employee"],
168+
"as_text": "This properties can not be present at the same time: student, employee."
164169
}
165170
]
166171
```
@@ -271,7 +276,8 @@ Returned error:
271276
{
272277
"error": JSONProperty.Errors.OBJECT_DEPENDENCY_ERROR,
273278
"main_property": "street",
274-
"dependent_property": "city"
279+
"dependent_property": "city",
280+
"as_text": "'street' property has been specified, but 'city' is missing."
275281
}
276282
]
277283
```
@@ -298,14 +304,14 @@ The public methods of this class are:
298304

299305
This class could directly raise any of the following errors:
300306

301-
| Enum value | Description | Params |
302-
|-|-|-|
303-
| COULD_NOT_OPEN_FILE | The file path leads to a nonexistent file or an error occurred when opening the file. | **code -> int:** <br> Error code returned by [File.open()](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File#class-file-method-open). |
304-
| EMPTY_FILE | The input file is empty. | None. |
305-
| JSON_PARSING_ERROR | An error occurred when parsing the JSON. These are only syntax errors. | **code -> int:** <br> Error returned by [JSONParseResult.get_error()](https://docs.godotengine.org/en/stable/classes/class_jsonparseresult.html#property-descriptions). <br> **line -> int:** <br> Line where the error ocurred. <br> **string -> String:** <br> Message that describes the error.|
306-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [OBJECT](./ENUMS.md).
307-
OBJECT_MISSING_PROPERTY | The input does not specify a required property. | **property -> String:** <br> Name of the required property. |
308-
OBJECT_NON_VALID_PROPERTY | The input specifies a property not defined by the structure. | **property -> String:** <br> Name of the non-valid property. |
309-
OBJECT_ONE_IS_REQUIRED | If the structure defines an array of exclusive properties, and it specifies that at least one must be present, this error arises whenever none of these properties are present. | **properties -> Array:** <br> List of names of the exclusive properties. |
310-
OBJECT_EXCLUSIVITY_ERROR | The input specifies two properties present in the same array of exclusive properties. | **properties -> Array:** <br> List of the exclusive properties specified in the input. |
311-
OBJECT_DEPENDENCY_ERROR | The main property is present in the input but not the dependent one | **main_property -> String:** <br> Name of the main property. <br> **dependent_property -> String:** <br> Name of the dependent property. |
307+
| Enum value | Description | Params | As text |
308+
|-|-|-|-|
309+
| COULD_NOT_OPEN_FILE | The file path leads to a nonexistent file or an error occurred when opening the file. | **code -> int:** <br> Error code returned by [File.open()](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File#class-file-method-open). | Could not open the file |
310+
| EMPTY_FILE | The input file is empty. | None. | The configuration file can not be empty |
311+
| JSON_PARSING_ERROR | An error occurred when parsing the JSON. These are only syntax errors. | **code -> int:** <br> Error returned by [JSONParseResult.get_error()](https://docs.godotengine.org/en/stable/classes/class_jsonparseresult.html#property-descriptions). <br> **line -> int:** <br> Line where the error ocurred. <br> **string -> String:** <br> Message that describes the error.| JSON parsing error at line {line}: \"{string}\" |
312+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [OBJECT](./ENUMS.md). | Wrong type: expected 'object' |
313+
OBJECT_MISSING_PROPERTY | The input does not specify a required property. | **property -> String:** <br> Name of the required property. | The property '{property}' has not been specified |
314+
OBJECT_NON_VALID_PROPERTY | The input specifies a property not defined by the structure. | **property -> String:** <br> Name of the non-valid property. | The property '{property}' is not a valid one |
315+
OBJECT_ONE_IS_REQUIRED | If the structure defines an array of exclusive properties, and it specifies that at least one must be present, this error arises whenever none of these properties are present. | **properties -> Array:** <br> List of names of the exclusive properties. | One of this properties needs to be specified: {properties} |
316+
OBJECT_EXCLUSIVITY_ERROR | The input specifies two properties present in the same array of exclusive properties. | **properties -> Array:** <br> List of the exclusive properties specified in the input. | This properties can not be present at the same time: {properties} |
317+
OBJECT_DEPENDENCY_ERROR | The main property is present in the input but not the dependent one | **main_property -> String:** <br> Name of the main property. <br> **dependent_property -> String:** <br> Name of the dependent property. | '{main_property}' property has been specified, but '{dependent_property}' is missing |

doc/files/JSON-PROPERTY-ARRAY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ The public methods of this class are:
1313
| **remove_max_size** | None. | Removes any maximum size boundary. | Nothing. |
1414
| **set_element_property** | **element_property -> JSONProperty:** <br> Object with the conditions that every element of the array must satisfy. | Sets the conditions that every element of the array must satisfy. | Nothing. |
1515
| **remove_element_property** | None. | Allows the elements of the array to be anything. | Nothing. |
16-
| **set_uniqueness** | **uniqueness -> bool:** <br> Determines if every object of the array must be different from each other. <br> **unique_key -> String (""):** <br> If the array has dictionaries as its elements, 'unique_key' determines which property to use when comparing if two of then are equal. <br><br> **WARNING:** An empty 'unique_key' means that every property of the dictionaries must be equal for them to be equal. | Determines if the elements of the array have to be unique. | Nothing.
16+
| **set_uniqueness** | **uniqueness -> bool:** <br> Determines if every object of the array must be different from each other. <br> **unique_key -> String (""):** <br> If the array has dictionaries as its elements, 'unique_key' determines which property to use when comparing if two of then are equal. <br><br> **WARNING:** An empty 'unique_key' means that every property of the dictionaries must be the same for them to be equal. | Determines if the elements of the array have to be unique. | Nothing.

doc/files/JSON-PROPERTY-BOOL.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ Returned error:
4848
{
4949
"error": JSONProperty.Errors.WRONG_TYPE,
5050
"expected": JSONProperty.Types.BOOL,
51-
"context": "bool"
51+
"context": "bool",
52+
"as_text": "Wrong type: expected 'boolean', at 'bool'."
5253
}
5354
]
5455
```
@@ -66,6 +67,6 @@ The public methods of this class are:
6667

6768
This class could directly raise any of the following errors:
6869

69-
| Enum value | Description | Params |
70-
|-|-|-|
71-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [BOOL](./ENUMS.md).
70+
| Enum value | Description | Params | As text |
71+
|-|-|-|-|
72+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [BOOL](./ENUMS.md). | Wrong type: expected 'boolean' |

doc/files/JSON-PROPERTY-COLOR.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Returned error:
5858
{
5959
"error": JSONProperty.Errors.WRONG_TYPE,
6060
"expected": JSONProperty.Types.COLOR,
61-
"context": "color"
61+
"context": "color",
62+
"as_text": "Wrong type: expected 'color', at 'color'."
6263
}
6364
]
6465
```
@@ -80,7 +81,8 @@ Returned error:
8081
{
8182
"error": JSONProperty.Errors.COLOR_WRONG_SIZE,
8283
"size": 1,
83-
"context": "color"
84+
"context": "color",
85+
"as_text": "The color is 1 element(s) long, when it should be 3 to 4, at 'color'."
8486
}
8587
]
8688
```
@@ -101,7 +103,8 @@ Returned error:
101103
[
102104
{
103105
"error": JSONProperty.Errors.COLOR_WRONG_TYPE,
104-
"context": "color/[0]"
106+
"context": "color/[0]",
107+
"as_text": "Wrong type: expected 'integer' in the range [0, 255], at 'color/[0]'."
105108
}
106109
]
107110
```
@@ -123,7 +126,8 @@ Returned error:
123126
{
124127
"error": JSONProperty.Errors.COLOR_OUT_OF_RANGE,
125128
"value": 256,
126-
"context": "color/[0]"
129+
"context": "color/[0]",
130+
"as_text": "256 is out of the range [0, 255], at 'color/[0]'."
127131
}
128132
]
129133
```
@@ -141,9 +145,9 @@ The public methods of this class are:
141145

142146
This class could directly raise any of the following errors:
143147

144-
| Enum value | Description | Params |
145-
|-|-|-|
146-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [COLOR](./ENUMS.md).
147-
| COLOR_WRONG_SIZE | The size of the color array is not 3 or 4. | **size -> int:** <br> The input size.
148-
| COLOR_WRONG_TYPE | The type of one of the color array elements is not an integer. | None.
149-
| COLOR_OUT_OF_RANGE | The value of one of the color array elements is not in the range [0, 256]. | **value -> int:** <br> The input value.
148+
| Enum value | Description | Params | As text |
149+
|-|-|-|-|
150+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [COLOR](./ENUMS.md). | Wrong type: expected 'color' |
151+
| COLOR_WRONG_SIZE | The size of the color array is not 3 or 4. | **size -> int:** <br> The input size. | The color is {size} element(s) long, when it should be 3 to 4 |
152+
| COLOR_WRONG_TYPE | The type of one of the color array elements is not an integer. | None. | Wrong type: expected 'integer' in the range [0, 255] |
153+
| COLOR_OUT_OF_RANGE | The value of one of the color array elements is not in the range [0, 256]. | **value -> int:** <br> The input value. | {value} is out of the range [0, 255] |

doc/files/JSON-PROPERTY-ENUM.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Returned error:
5757
{
5858
"error": JSONProperty.Errors.WRONG_TYPE,
5959
"expected": JSONProperty.Types.ENUM,
60-
"context": "enum"
60+
"context": "enum",
61+
"as_text": "Wrong type: expected 'string', at 'enum'."
6162
}
6263
]
6364
```
@@ -79,7 +80,8 @@ Returned error:
7980
{
8081
"error": JSONProperty.Errors.ENUM_NOT_VALID,
8182
"value": "FOURTH",
82-
"context": "enum"
83+
"context": "enum",
84+
"as_text": "'FOURTH' is not in the list of valid values, at 'enum'."
8385
}
8486
]
8587
```
@@ -98,7 +100,7 @@ The public methods of this class are:
98100

99101
This class could directly raise any of the following errors:
100102

101-
| Enum value | Description | Params |
102-
|-|-|-|
103-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [ENUM](./ENUMS.md).
104-
| ENUM_NOT_VALID | The input is not present in the list of possible values. | **value -> String:** <br> The input value.
103+
| Enum value | Description | Params | As text |
104+
|-|-|-|-|
105+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [ENUM](./ENUMS.md). | Wrong type: expected 'string' |
106+
| ENUM_NOT_VALID | The input is not present in the list of possible values. | **value -> String:** <br> The input value. | '{value}' is not in the list of valid values |

doc/files/JSON-PROPERTY-INTEGER.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Returned error:
5757
{
5858
"error": JSONProperty.Errors.WRONG_TYPE,
5959
"expected": JSONProperty.Types.INTEGER,
60-
"context": "integer"
60+
"context": "integer",
61+
"as_text": "Wrong type: expected 'integer', at 'integer'."
6162
}
6263
]
6364
```
@@ -80,7 +81,8 @@ Returned error:
8081
"error": JSONProperty.Errors.NUMBER_VALUE_LESS_THAN_MIN,
8182
"value": -1,
8283
"min": 0,
83-
"context": "integer"
84+
"context": "integer",
85+
"as_text": "-1 is less than the minimum allowed (0), at 'integer'."
8486
}
8587
]
8688
```
@@ -103,7 +105,8 @@ Returned error:
103105
"error": JSONProperty.Errors.NUMBER_VALUE_MORE_THAN_MAX,
104106
"value": 11,
105107
"max": 10,
106-
"context": "integer"
108+
"context": "integer",
109+
"as_text": "11 is more than the maximum allowed (10), at 'integer'."
107110
}
108111
]
109112
```
@@ -125,9 +128,9 @@ The public methods of this class are:
125128

126129
This class could directly raise any of the following errors:
127130

128-
| Enum value | Description | Params |
129-
|-|-|-|
130-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [INTEGER](./ENUMS.md).
131-
| NUMBER_VALUE_LESS_THAN_MIN | The value of the input is less than the minimum. | **value -> int:** <br> The input value. <br> **min -> int:** <br> The minimum value allowed.
132-
| NUMBER_VALUE_MORE_THAN_MAX | The value of the input is more than the maximum. | **value -> int:** <br> The input value. <br> **max -> int:** <br> The maximum value allowed.
131+
| Enum value | Description | Params | As text |
132+
|-|-|-|-|
133+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [INTEGER](./ENUMS.md). | Wrong type: expected 'integer' |
134+
| NUMBER_VALUE_LESS_THAN_MIN | The value of the input is less than the minimum. | **value -> int:** <br> The input value. <br> **min -> int:** <br> The minimum value allowed. | {value} is less than the minimum allowed ({min}) |
135+
| NUMBER_VALUE_MORE_THAN_MAX | The value of the input is more than the maximum. | **value -> int:** <br> The input value. <br> **max -> int:** <br> The maximum value allowed. | {value} is more than the maximum allowed ({max}) |
133136

doc/files/JSON-PROPERTY-NUMBER.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Returned error:
5757
{
5858
"error": JSONProperty.Errors.WRONG_TYPE,
5959
"expected": JSONProperty.Types.NUMBER,
60-
"context": "number"
60+
"context": "number",
61+
"as_text": "Wrong type: expected 'number', at 'number'."
6162
}
6263
]
6364
```
@@ -80,7 +81,8 @@ Returned error:
8081
"error": JSONProperty.Errors.NUMBER_VALUE_LESS_THAN_MIN,
8182
"value": -0.1,
8283
"min": 0.0,
83-
"context": "number"
84+
"context": "number",
85+
"as_text": "-0.100 is less than the minimum allowed (0.000), at 'number'."
8486
}
8587
]
8688
```
@@ -103,7 +105,8 @@ Returned error:
103105
"error": JSONProperty.Errors.NUMBER_VALUE_MORE_THAN_MAX,
104106
"value": 10.1,
105107
"max": 10.0,
106-
"context": "number"
108+
"context": "number",
109+
"as_text": "10.100 is more than the maximum allowed (10.000), at 'number'."
107110
}
108111
]
109112
```
@@ -125,8 +128,8 @@ The public methods of this class are:
125128

126129
This class could directly raise any of the following errors:
127130

128-
| Enum value | Description | Params |
129-
|-|-|-|
130-
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [NUMBER](./ENUMS.md).
131-
| NUMBER_VALUE_LESS_THAN_MIN | The value of the input is less than the minimum. | **value -> float:** <br> The input value. <br> **min -> float:** <br> The minimum value allowed.
132-
| NUMBER_VALUE_MORE_THAN_MAX | The value of the input is more than the maximum. | **value -> float:** <br> The input value. <br> **max -> float:** <br> The maximum value allowed.
131+
| Enum value | Description | Params | As text |
132+
|-|-|-|-|
133+
| WRONG_TYPE | The type of the input does not match the expected one. | **expected -> int:** <br> Takes the value [NUMBER](./ENUMS.md). | Wrong type: expected 'number' |
134+
| NUMBER_VALUE_LESS_THAN_MIN | The value of the input is less than the minimum. | **value -> float:** <br> The input value. <br> **min -> float:** <br> The minimum value allowed. | {value} is less than the minimum allowed ({min}) |
135+
| NUMBER_VALUE_MORE_THAN_MAX | The value of the input is more than the maximum. | **value -> float:** <br> The input value. <br> **max -> float:** <br> The maximum value allowed. | {value} is more than the maximum allowed ({max}) |

0 commit comments

Comments
 (0)