Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
LabComm
Commits
798b5d29
Commit
798b5d29
authored
May 25, 2015
by
Anders Blomdell
Browse files
Slowly improving error handling.
parent
bf75c6b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/c/2014/labcomm2014_decoder.c
View file @
798b5d29
...
...
@@ -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:
...
...
lib/c/2014/labcomm2014_error.c
View file @
798b5d29
...
...
@@ -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
);
v
f
printf
(
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
);
v
f
printf
(
stderr
,
format
,
args
);
va_end
(
args
);
exit
(
1
);
...
...
lib/c/2014/labcomm2014_error.h
View file @
798b5d29
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment