public bool FillFromException(Exception exception) { IsSucceed = false; ErrorInfo = new GoogleDriveErrorInfo(); if (exception is Google.GoogleApiException) { var ex = (Google.GoogleApiException)exception; ErrorInfo.ErrorMessage = ex.Error?.Message ?? (ex.Message ?? ex.ToString()); ErrorInfo.HttpErrorCode = (int)ex.HttpStatusCode; return(true); } else if (exception is Google.Apis.Auth.OAuth2.Responses.TokenResponseException) { var ex = (Google.Apis.Auth.OAuth2.Responses.TokenResponseException)exception; ErrorInfo.ErrorMessage = ex.Error?.ToString() ?? (ex.Message ?? ex.ToString()); if (ex.StatusCode != null) { ErrorInfo.HttpErrorCode = (int)ex.StatusCode; } return(true); } return(false); }
public ResultData Run(StepStartData data) { try { Connection connection = CreateConnection(data); GoogleDriveBaseResult res = ExecuteStep(connection, data); if (res.IsSucceed) { var outputData = OutcomeScenarios[RESULT_OUTCOME_INDEX].OutputData; var exitPointName = OutcomeScenarios[RESULT_OUTCOME_INDEX].ExitPointName; if (outputData != null && outputData.Length > 0) { return(new ResultData(exitPointName, new DataPair[] { new DataPair(outputData[0].Name, res.DataObj) })); } else { return(new ResultData(exitPointName)); } } else { return(new ResultData(ERROR_OUTCOME, new DataPair[] { new DataPair(ERROR_OUTCOME_DATA_NAME, res.ErrorInfo) })); } } catch (Exception ex) { GoogleDriveErrorInfo ErrInfo = new GoogleDriveErrorInfo() { ErrorMessage = ex.ToString(), HttpErrorCode = null }; return(new ResultData(ERROR_OUTCOME, new DataPair[] { new DataPair(ERROR_OUTCOME_DATA_NAME, ErrInfo) })); } }