Fix missing error code

Add error handling when error code is not defined.