Set ErrorCode for returned errors