check if error is defined

sometimes useful when reuse template