Implemented custom errors management

Signed-off-by: Alessandro Vioni <jenoma@gmail.com>