Add support for errors

Signed-off-by: Constantin MUSCĂ <constantin.musca@gmail.com>