[errors] better error handling