Added codes to error handling

Signed-off-by: Ondrej Koch <o.koch@zerusnet.com>