Rename field of m_exception_t
This commit is contained in:
1 parent
ef0e849616
commit
42111ec22a
3 files changed
+15
-12
No files matched your search
@@ -125,7 +125,7 @@ Other headers offering other functionality are:
|
|||||||
* [m-bitset.h](#m-bitset): header for creating bit set (or "packed array of bool"),
|
* [m-bitset.h](#m-bitset): header for creating bit set (or "packed array of bool"),
|
||||||
* [m-algo.h](#m-algo): header for providing various generic algorithms to the previous containers.
|
* [m-algo.h](#m-algo): header for providing various generic algorithms to the previous containers.
|
||||||
* [m-funcobj.h](#m-funcobj): header for creating function object (used by algorithm generation).
|
* [m-funcobj.h](#m-funcobj): header for creating function object (used by algorithm generation).
|
||||||
* [m-try.h][#m-try): header for handling errors as exceptions,
|
* [m-try.h](#m-try): header for handling errors as exceptions,
|
||||||
* [m-mempool.h](#m-mempool): header for creating specialized & fast memory allocator.
|
* [m-mempool.h](#m-mempool): header for creating specialized & fast memory allocator.
|
||||||
* [m-worker.h](#m-worker): header for providing an easy pool of workers on separated threads to handle work orders, used for parallelism tasks.
|
* [m-worker.h](#m-worker): header for providing an easy pool of workers on separated threads to handle work orders, used for parallelism tasks.
|
||||||
* [m-serial-json.h](#m-serial-json): header for importing / exporting the containers in [JSON format](https://en.wikipedia.org/wiki/JSON).
|
* [m-serial-json.h](#m-serial-json): header for importing / exporting the containers in [JSON format](https://en.wikipedia.org/wiki/JSON).
|
||||||
@@ -7750,8 +7750,10 @@ This is the exception type. It is composed of the following fields:
|
|||||||
* error\_code: The error code. It is used to identify the error that are raised the exception.
|
* error\_code: The error code. It is used to identify the error that are raised the exception.
|
||||||
* line: The line number where the error was detected.
|
* line: The line number where the error was detected.
|
||||||
* filename: The filename (CSTR) where the error was detected.
|
* filename: The filename (CSTR) where the error was detected.
|
||||||
* n: Number of entries in 'error' table
|
* n: Number of entries in 'data' table
|
||||||
* error: an array of M\_USE\_MAX\_EXCEPTION elements.
|
* data: an array of M\_USE\_MAX\_EXCEPTION elements.
|
||||||
|
|
||||||
|
You can access the fields of the type directly.
|
||||||
|
|
||||||
#### M\_TRY(name)
|
#### M\_TRY(name)
|
||||||
|
|
||||||
@@ -7775,6 +7777,7 @@ Throw the exception associated to the error\_code.
|
|||||||
error\_code shall be a positive integer constant.
|
error\_code shall be a positive integer constant.
|
||||||
Additional arguments are used to fill in the error field of m\_exception\_s
|
Additional arguments are used to fill in the error field of m\_exception\_s
|
||||||
that is used to identify the cause of the exception.
|
that is used to identify the cause of the exception.
|
||||||
|
The line and filename fields of the exception are filled automatically by the macro.
|
||||||
|
|
||||||
|
|
||||||
### M-MEMPOOL
|
### M-MEMPOOL
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ struct m_exception_s {
|
|||||||
unsigned short line; // Line number where the error was detected
|
unsigned short line; // Line number where the error was detected
|
||||||
unsigned short n; // Number of entries in 'error' table
|
unsigned short n; // Number of entries in 'error' table
|
||||||
const char *filename; // filename where the error was detected
|
const char *filename; // filename where the error was detected
|
||||||
intptr_t error[M_USE_MAX_EXCEPTION]; // Error specific data
|
intptr_t data[M_USE_MAX_EXCEPTION]; // Specific data of the exception
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
m_exception_s<N> *operator->() { return this; }
|
m_exception_s<N> *operator->() { return this; }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-8
@@ -32,7 +32,7 @@ static void test_throw(void)
|
|||||||
M_THROW(67, 56);
|
M_THROW(67, 56);
|
||||||
} M_CATCH(protect, 67) {
|
} M_CATCH(protect, 67) {
|
||||||
assert(protect->n == 1);
|
assert(protect->n == 1);
|
||||||
M_THROW(M_ERROR_MEMORY, protect->error[0], 4, 6, 8);
|
M_THROW(M_ERROR_MEMORY, protect->data[0], 4, 6, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ static void test1(void)
|
|||||||
} M_CATCH(test2, M_ERROR_ACCESS) {
|
} M_CATCH(test2, M_ERROR_ACCESS) {
|
||||||
assert(flow++ == 6);
|
assert(flow++ == 6);
|
||||||
assert(test2->n == 1);
|
assert(test2->n == 1);
|
||||||
assert(test2->error[0] == 12);
|
assert(test2->data[0] == 12);
|
||||||
}
|
}
|
||||||
} M_CATCH(test1, M_ERROR_MEMORY) {
|
} M_CATCH(test1, M_ERROR_MEMORY) {
|
||||||
assert(0);
|
assert(0);
|
||||||
@@ -130,8 +130,8 @@ static void test1(void)
|
|||||||
} M_CATCH(test1, 42) {
|
} M_CATCH(test1, 42) {
|
||||||
assert(flow++ == 6);
|
assert(flow++ == 6);
|
||||||
assert(test1->n == 2);
|
assert(test1->n == 2);
|
||||||
assert(test1->error[0] == 1);
|
assert(test1->data[0] == 1);
|
||||||
assert(test1->error[1] == 3);
|
assert(test1->data[1] == 3);
|
||||||
}
|
}
|
||||||
assert(flow ++ == 7);
|
assert(flow ++ == 7);
|
||||||
|
|
||||||
@@ -192,10 +192,10 @@ static void test1(void)
|
|||||||
} M_CATCH(test1, M_ERROR_MEMORY) {
|
} M_CATCH(test1, M_ERROR_MEMORY) {
|
||||||
assert(flow ++ == 4);
|
assert(flow ++ == 4);
|
||||||
assert(test1->n == 4);
|
assert(test1->n == 4);
|
||||||
assert(test1->error[0] == 56);
|
assert(test1->data[0] == 56);
|
||||||
assert(test1->error[1] == 4);
|
assert(test1->data[1] == 4);
|
||||||
assert(test1->error[2] == 6);
|
assert(test1->data[2] == 6);
|
||||||
assert(test1->error[3] == 8);
|
assert(test1->data[3] == 8);
|
||||||
} M_CATCH(test1, 42) {
|
} M_CATCH(test1, 42) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user