common: improve error management