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: doc/user_manual.md
+32-92Lines changed: 32 additions & 92 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,125 +124,65 @@ struct cjlib_json_error
124
124
125
125
# Error related functions
126
126
Cjlib provides the errors by manipulating an internal (private) variable in the implementation of cjlib_error.c file. This is done to protect it from mistaken actions. To access the private variable that has the information about the error that occurred, the library provides the following functions. Each of the following functions is **thread safe**, as it uses mutex, to allow multiple threads to check for errors (if this is necessary).
127
-
128
127
___
129
-
## cjlib_json_error_init
128
+
## cjlib_json_get_error
130
129
___
131
130
### Description
132
-
It is used to make the required initializations on the memory where the internal structure representing the errors is stored.
133
-
134
-
### Function signature
135
-
```C
136
-
intcjlib_json_error_init(void)
137
-
```
138
-
139
-
### Parameters
140
-
No parameters are required.
141
-
142
-
### Return
143
-
An integer indicating whether the initialization succeeded. If succeed, 0 is returned, otherwise -1.
131
+
The cjlib_json_get error is leveraged to request the error produced by a function. It is typically used after a function fails to get more details about the error that occurred internally in the library. Each of the library functions returns a subset of the available errors; thus, there is no need to check for all the errors for each function. The possible errors from each library function are documented.
144
132
145
-
### Errors
146
-
No specific error is returned.
147
-
148
-
### Example
149
-
```C
150
-
#include "cjlib_error.h"
151
-
#include <stdio.h>
152
-
#include <stdlib.h>
153
-
154
-
int main(void) {
155
-
if (-1 == cjlib_json_error_init()) {
156
-
(void) printf("Failed to initialize JSON errors\n");
157
-
exit(EXIT_FAILURE);
158
-
}
159
-
return EXIT_SUCCESS;
160
-
}
161
-
```
162
-
163
-
___
164
-
## cjlib_json_error_destroy
165
-
___
166
-
### Description
167
-
Is used to release the resources that was allocated for the internal error structure.
133
+
The user may ignore the errors retrieved from the internal error structure but must always check if a library function is erroneous. Otherwise, unexpected behavior may occur, breaking the program.
0 commit comments