[enh] improved error handling