You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/errors.md
+31-2Lines changed: 31 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,38 @@ In this context, value means either "member of object" or "index of array"
6
6
7
7
## Get
8
8
9
-
-`ERROR_VALUE_NOT_FOUND`
9
+
-`ERROR_NOT_FOUND`
10
10
- Attempted to access a value that does not exist
11
11
-`ERROR_VALUE_INCORRECT_TYPE`
12
12
- Attempted to access a value that has the wrong type. This can happen if the query uses `.[30]` to get an array index, but an object exists instead. It can also happen if the user writes `get-string`, and it found a non-string value after evaluating the query. It can also happen if the user writes `set-string`, and the place to write the new value already has a value of a different type
13
-
-`ERROR_INTERNAL_INVALID_VOBJ`
13
+
-`ERROR_VOBJ_INVALID_TYPE`
14
14
- The virtual object (a string that contains a reference to the real global object) had keys with unexpected values. You shouldn't get this error unless something has seriously gone wrong
15
+
16
+
# Handling
17
+
18
+
Because Bash often does the wrong thing silently, it's important to fail early when any inputs are unexpected. `bash-object` does this at every level
19
+
20
+
Below, if any of the assurances do not pass, `bash-object` will fail with a non-zero exit code. For some of these, `VERIFY_BASH_OBJECT` must be a variable
21
+
22
+
23
+
1. Argument parsing
24
+
25
+
- Ensures the correct number of arguments are passed (when applicable)
26
+
- Ensures the arguments are not empty (when applicable)
27
+
- Ensures applicable arguments refers to real variables (ex. the root object in both set/get, and the final_value for set)
28
+
- Ensure applicable arguments refer to variables of the same type (for set)
29
+
30
+
2. Query parsing
31
+
32
+
- Ensures the query has the correct form
33
+
34
+
3. Tree traversing
35
+
36
+
- Ensure type specified in the virtual object matches that of the referenced object
37
+
- Ensure type implied in query string matches the one specified in the virtual object
38
+
39
+
4. Final operation (set/get)
40
+
41
+
- Ensure type specified in the virtual object matches that of the referenced object
42
+
- Ensure type implied in query string matches the one specified in the virtual object
43
+
- Ensure type specified in set/get matches the one specified in the virtual object
bash_object.util.die 'ERROR_VOBJ_INCORRECT_TYPE'"Virtual object has a reference of type '$vmd_dtype', but when dereferencing, a variable of type '$current_object_type' was found"
127
+
return
128
+
fi
129
+
;;
130
+
array)
131
+
if [ "$current_object_type"!= array ];then
132
+
bash_object.util.die 'ERROR_VOBJ_INCORRECT_TYPE'"Virtual object has a reference of type '$vmd_dtype', but when dereferencing, a variable of type '$current_object_type' was found"
0 commit comments