lib: proper erro reporting