Make working with errors in more right way (like with exceptions)

Signed-off-by: Slava Zanko <slavazanko@gmail.com>