Skip to content
Snippets Groups Projects
Commit 798b5d29 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Slowly improving error handling.

parent bf75c6b2
No related branches found
No related tags found
No related merge requests found
......@@ -199,6 +199,12 @@ free_signature_signature:
labcomm2014_memory_free(d->memory, 1, signature.signature);
free_signature_name:
if (signature.name) {
if (result == -ENOENT) {
labcomm2014_error_warning(d->error,
LABCOMM2014_ERROR_DEC_NO_REG_SIGNATURE,
"Signature not found: %s\n",
signature.name);
}
labcomm2014_memory_free(d->memory, 0, signature.name);
}
out:
......
......@@ -24,15 +24,21 @@
#include <stdarg.h>
#include "labcomm2014_error.h"
static char *description[] = {
#define LABCOMM2014_ERROR(name, description) description ,
#include "labcomm2014_error.h"
#undef LABCOMM2014_ERROR
};
void labcomm2014_error_fatal_global(enum labcomm2014_error error,
char *format,
...)
{
va_list args;
fprintf(stderr, "Fatal error %d\n", error);
fprintf(stderr, "Fatal error %d (%s)\n", error, description[error]);
va_start(args, format);
vprintf(format, args);
vfprintf(stderr, format, args);
va_end(args);
exit(1);
......@@ -45,9 +51,9 @@ void labcomm2014_error_warning(struct labcomm2014_error_handler *e,
{
va_list args;
fprintf(stderr, "Fatal warning %d\n", error);
fprintf(stderr, "Fatal warning %d (%s)\n", error, description[error]);
va_start(args, format);
vprintf(format, args);
vfprintf(stderr, format, args);
va_end(args);
exit(1);
......
......@@ -52,6 +52,9 @@ LABCOMM2014_ERROR(LABCOMM2014_ERROR_ENC_NO_REG_SIGNATURE,
"Encoder has no registration for this signature")
LABCOMM2014_ERROR(LABCOMM2014_ERROR_ENC_BUF_FULL,
"The labcomm2014 buffer is full")
LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_NO_REG_SIGNATURE,
"Decoder has no registration for this signature")
LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_UNKNOWN_DATATYPE,
"Decoder: Unknown datatype")
LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_INDEX_MISMATCH,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment