mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-05 11:00:36 +01:00
Introduced qmckl_last_error
This commit is contained in:
parent
2aa904bed9
commit
7ad69a5426
@ -554,7 +554,44 @@ if (x < 0) {
|
|||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* Last error
|
||||||
|
|
||||||
|
Returns a string describing the last error, using ~qmckl_get_error~.
|
||||||
|
|
||||||
|
# Header
|
||||||
|
#+begin_src c :comments org :tangle (eval h_func)
|
||||||
|
qmckl_exit_code
|
||||||
|
qmckl_last_error(qmckl_context context, char* buffer);
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
# Source
|
||||||
|
#+begin_src c :tangle (eval c) :exports none
|
||||||
|
qmckl_exit_code
|
||||||
|
qmckl_last_error(qmckl_context context, char* buffer) {
|
||||||
|
|
||||||
|
char function_name[QMCKL_MAX_FUN_LEN];
|
||||||
|
char message[QMCKL_MAX_MSG_LEN];
|
||||||
|
|
||||||
|
qmckl_exit_code rc, last_rc;
|
||||||
|
|
||||||
|
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||||
|
strncpy(buffer, "Null context", 13);
|
||||||
|
return QMCKL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = qmckl_get_error(context, &last_rc, function_name, message);
|
||||||
|
if (rc != QMCKL_SUCCESS) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(buffer, "Error -- %s -- in %s\n%s",
|
||||||
|
qmckl_string_of_error(last_rc),
|
||||||
|
function_name, message);
|
||||||
|
|
||||||
|
return QMCKL_SUCCESS;
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
* End of files :noexport:
|
* End of files :noexport:
|
||||||
|
|
||||||
#+begin_src c :comments link :tangle (eval h_private_type)
|
#+begin_src c :comments link :tangle (eval h_private_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user