상속: System.Exception
예제 #1
0
파일: TeamManager.cs 프로젝트: gwupe/Gwupe
 private static DataSubmissionException CompileDataSubmissionException(List<String> validationErrors)
 {
     var exception = new DataSubmissionException();
     if (validationErrors != null)
     {
         if (validationErrors.Contains(SignupRs.SignupErrorEmailAddressInUse))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "email",
                 ErrorCode = DataSubmitErrorCode.InUse
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorEmailAddressInvalid))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "email",
                 ErrorCode = DataSubmitErrorCode.EmailInvalid
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorUserExists))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "username",
                 ErrorCode = DataSubmitErrorCode.InUse
             });
         }
         if (validationErrors.Contains(SignupRs.SignupErrorPasswordComplexity))
         {
             exception.SubmitErrors.Add(new DataSubmitError()
             {
                 FieldName = "password",
                 ErrorCode = DataSubmitErrorCode.NotComplexEnough
             });
         }
     }
     return exception;
 }
예제 #2
0
파일: TeamManager.cs 프로젝트: gwupe/Gwupe
 public void UpdateTeam(string username)
 {
     Team team = null;
     try
     {
         team = GetTeamByUsername(username);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to find team " + username);
         var exception = new DataSubmissionException();
         exception.SubmitErrors.Add(new DataSubmitError()
         {
             FieldName = "username",
             ErrorCode = DataSubmitErrorCode.InvalidKey
         });
         throw exception;
     }
     ElevateToken token = GwupeClientAppContext.CurrentAppContext.Elevate("In order to update this team, please enter your current password.");
     var request = new UpdateTeamRq()
     {
         teamElement = new TeamElement()
         {
             avatarData = team.Avatar == null ? null : Convert.ToBase64String(team.Avatar),
             description = team.Description,
             email = team.Email,
             firstname = team.Firstname,
             location = team.Location,
             supporter = team.Supporter,
             user = team.Username
         },
         playerRequest = team.PlayerRequest,
         admin = team.Admin,
         securityKey = token.SecurityKey,
         tokenId = token.TokenId
     };
     try
     {
         var response = GwupeClientAppContext.CurrentAppContext.ConnectionManager.Connection
             .Request<UpdateTeamRq, UpdateTeamRs>(
                 request);
         GwupeClientAppContext.CurrentAppContext.PartyManager.AddUpdatePartyFromElement(response.teamElement);
     }
     catch (MessageException<UpdateTeamRs> ex)
     {
         Logger.Error("Failed to update team", ex);
         var exception = CompileDataSubmissionException(ex.Response.validationErrors);
         throw exception;
     }
 }