in the C language there isn't the statement try/catch. How can I handle the errors?
2 Answers
C libraries use different mechanisms for error handling:
The return value of each function may contain an error value. The caller then needs to verify, after each function call, that the return value indicates a non-error state. For example most functions in <unistd.h>
.
Some use a global variable which is set to a non-zero value when an error occured. For example, on failure, fopen
sets errno
(global variable from C standard library) to an error value, and also returns -1
instead of a file descriptor. This is also part of the C standard, see: http://en.cppreference.com/w/c/error/errno.
Finally exception handling like in C++ may be simulated using longjmp
: The calles first calls setjmp
at a given place in code. The library function, when it fails, then jumps directly to that place using longjmp
. For example libpng
does this, as described in http://www.libpng.org/pub/png/libpng-manual.txt. But there are several difficulties with this.

- 8,533
- 5
- 31
- 84
I totally agree with @tmlen and more added for the Tizen specific,
You can catch a error with get_last_error()
if the error is originated from Tizen Native API.
int get_last_result (void);
char* get_error_message (int err);
And errors from EFL can caught with eina_error_get()
/eina_error_msg_get()
but unfortunately Tizen 2.4 does not support eina error functions. it support only error type. (I can't understand about EFL guys in samsung...)

- 1,164
- 1
- 12
- 28