Add error code check

Signed-off-by: Dima Kuznetsov <dkuznets@redhat.com>