Add error code to error objects