コード例 #1
3
ファイル: LogWriter.cs プロジェクト: affecto/dotnet-Logging
        public void WriteLog(ICorrelation correlation, LogEventLevel eventLevel, Exception exception, string formatMessage, params object[] args)
        {
            if (log == null)
            {
                log = loggerRepository.GetLogger(sourceType);
            }

            if (eventLevel == LogEventLevel.Verbose && !log.IsDebugEnabled)
            {
                return;
            }

            if (args != null && args.Length != 0)
            {
                formatMessage = string.Format(formatMessage, args);
            }

            log4net.Core.ILogger logger = log.Logger;

            LoggingEvent logEvent = new LoggingEvent(sourceType, logger.Repository, logger.Name, MapEventLevel(eventLevel), formatMessage, exception);

            if (correlation != null)
            {
                logEvent.Properties["CallerId"] = correlation.CallerId;
                logEvent.Properties["CorrelationId"] = correlation.CorrelationId;
            }

            logger.Log(logEvent);
        }
コード例 #2
1
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
     {
         return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InternalException"))
     {
         return new InternalException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidInputException"))
     {
         return new InvalidInputException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchEntityException"))
     {
         return new NoSuchEntityException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("OperationInProgressException"))
     {
         return new OperationInProgressException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonInspectorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
コード例 #3
1
ファイル: Program.cs プロジェクト: RobotCaleb/OpenRA
        static StringBuilder BuildExceptionReport(Exception e, StringBuilder sb, int d)
        {
            if (e == null)
                return sb;

            sb.AppendFormat("Exception of type `{0}`: {1}", e.GetType().FullName, e.Message);

            var tle = e as TypeLoadException;
            if (tle != null)
            {
                sb.AppendLine();
                Indent(sb, d);
                sb.AppendFormat("TypeName=`{0}`", tle.TypeName);
            }
            else // TODO: more exception types
            {
            }

            if (e.InnerException != null)
            {
                sb.AppendLine();
                Indent(sb, d); sb.Append("Inner ");
                BuildExceptionReport(e.InnerException, sb, d + 1);
            }

            sb.AppendLine();
            Indent(sb, d); sb.Append(e.StackTrace);

            return sb;
        }
コード例 #4
1
 private void RepoteUnhandleException(Exception ex)
 {
     Button b= new Button() ;
     Window w = new Window {Width = 0x258,Height = 0x1f4,Padding = new Thickness(0x14),Title = String.Format("{0} - {1}","予期せぬエラー","TwVideoUp")};
     StackPanel m = new StackPanel()
     {
         Orientation = Orientation.Vertical,
         Children =
         {
             new TextBlock()
             {
                 Text = "予期せぬエラーが発生しました。以下のStackTraceをIssueとして提出いただけると嬉しいです。(ユーザー名などが含まれている場合は伏せていただいて構いません。)",
                 TextWrapping = TextWrapping.Wrap
             },
             new TextBox()
             {
                 Text = ex.ToString(),
                 IsReadOnly = true,
                 TextWrapping = TextWrapping.Wrap,
                 Margin = new Thickness(10),
                 MaxHeight = 380,
                 VerticalScrollBarVisibility = ScrollBarVisibility.Auto
             },
             b
         },
     };
     b.Click += (sender, args) => Clipboard.SetText(ex.ToString());
     b.Content = new TextBlock() {Text = "Copy to Clipboard."};
     w.Content = m;
     w.ShowDialog();
     Shutdown();
 }
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue"))
            {
                return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination"))
            {
                return new InvalidParameterCombinationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidCacheParameterGroupState"))
            {
                return new InvalidCacheParameterGroupStateException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("CacheParameterGroupNotFound"))
            {
                return new CacheParameterGroupNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            return new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
コード例 #6
1
		public void ConstructorWithMessageAndInnerExceptionWorks() {
			var inner = new Exception("a");
			var ex = new FormatException("The message", inner);
			Assert.IsTrue((object)ex is FormatException, "is FormatException");
			Assert.IsTrue(ReferenceEquals(ex.InnerException, inner), "InnerException");
			Assert.AreEqual(ex.Message, "The message");
		}
public void TraverseForThrowsArgumentNullException861()
{
    Exception exception;
    object o;
    exception = new Exception();
    o = this.TraverseFor<object>(exception);
}
コード例 #8
1
        public void Log4NetLogger_LoggingTest()
        {
            string message = "Error Message";
            Exception ex = new Exception();
            string messageFormat = "Message Format: message: {0}, exception: {1}";

            ILog log = new Log4NetLogger(GetType());
            Assert.IsNotNull(log);

            log.Debug(message);
            log.Debug(message, ex);
            log.DebugFormat(messageFormat, message, ex.Message);

            log.Error(message);
            log.Error(message, ex);
            log.ErrorFormat(messageFormat, message, ex.Message);

            log.Fatal(message);
            log.Fatal(message, ex);
            log.FatalFormat(messageFormat, message, ex.Message);

            log.Info(message);
            log.Info(message, ex);
            log.InfoFormat(messageFormat, message, ex.Message);

            log.Warn(message);
            log.Warn(message, ex);
            log.WarnFormat(messageFormat, message, ex.Message);
        }
コード例 #9
1
    public override string FormatException(Exception exception)
    {
      while (exception is TargetInvocationException)
      {
        exception = exception.InnerException;
      }
      Builtins.lastException = exception;

      if (exception is Builtins.Continuation)
      {
        // cheat
        return @"&implementation-restriction
&message:             continuations cannot be used in this way, sorry :(";
      }

      if (exception is ThreadAbortException)
      {
        return "evaluation aborted";
      }

      if (exception is SchemeException)
      {
        return exception.ToString();
      }

      var w = new IronScheme.Runtime.StringWriter();
      w.WriteLine("Unhandled CLR exception reading input:");
      "(display {0} {1})".Eval(exception, w);
      return w.GetBuffer();
    }
コード例 #10
1
ファイル: PrintForm.cs プロジェクト: sgon1853/UPM_MDD_Thesis
        /// <summary>
        /// Initialize the form
        /// </summary>
        public void Initialize(List<Oid> selectedOids)
        {
            mSelectedOids = selectedOids;

            // If no instances selected, inform and exit
            if (mSelectedOids == null || mSelectedOids.Count == 0)
            {
                string lMessageError = CultureManager.TranslateString(LanguageConstantKeys.L_NO_SELECTION, LanguageConstantValues.L_NO_SELECTION);
                Exception lException = new Exception(lMessageError, null);
                ScenarioManager.LaunchErrorScenario(lException);
                return;
            }

            cmbBoxSelectTemplate.SelectedIndexChanged += new EventHandler(HandlecmbBoxSelectTemplate_SelectedIndexChanged);

            // Load the templates from configuration file and fill the Combo
            LoadReportTemplates();

            // Show the number of selected instances in the Title.
            Text = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ELEMENTSELECTED, LanguageConstantValues.L_ELEMENTSELECTED, mSelectedOids.Count);
            // Set the default printer
            lblNameOfPrint.Text = printDlg.PrinterSettings.PrinterName;

            ShowDialog();
        }
 public ObjectDataSourceStatusEventArgs(object returnValue, IDictionary outputParameters, System.Exception exception)
 {
     this._affectedRows = -1;
     this._returnValue = returnValue;
     this._outputParameters = outputParameters;
     this._exception = exception;
 }
コード例 #12
1
 /// <summary>
 /// Constructs an <see cref="LinkedINHttpResponseException"/>.
 /// </summary>
 /// <param name="expectedStatusCode">The expected <see cref="HttpStatusCode"/> of the response.</param>
 /// <param name="actualStatusCode">The actual <see cref="HttpStatusCode"/> of the response.</param>
 /// <param name="message">The message descriving the cause of this exception.</param>
 /// <param name="inner">The inner <see cref="Exception"/>.</param>
 public LinkedINHttpResponseException( HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, string message, Exception inner )
     : base(message, inner)
 {
     // set values
     ExpectedStatusCode = expectedStatusCode;
     ActualStatusCode = actualStatusCode;
 }
コード例 #13
1
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InternalErrorException"))
     {
         return new InternalErrorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
     {
         return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NotAuthorizedException"))
     {
         return new NotAuthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
     {
         return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
     {
         return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCognitoIdentityException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
コード例 #14
1
ファイル: ResponseShim.cs プロジェクト: peterson1/ErrH
        internal ResponseShim(IRestResponse resp,
                              IRequestShim req,
                              string baseUrl,
                              Exception error)
        {
            this.Request = req;

            if (resp != null)
            {
                this.Code = resp.StatusCode;
                this.Message = resp.StatusDescription;
                //this.Content = Convert.ToBase64String(resp.RawBytes);
                this.Content = UTF8Encoding.UTF8.GetString(
                                resp.RawBytes, 0, resp.RawBytes.Length);
                this.IsSuccess = resp.IsSuccess;
            }

            this.BaseUrl = baseUrl;
            this.Error = error;

            var restErr = error as RestServiceException;
            if (restErr != null)
            {
                this.Code = restErr.Code;
                this.Message = restErr.Message;
            }
        }
コード例 #15
1
 /// <summary>
 /// Initializes a new instance of the PipelineException class with the specified error message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">A message that describes the error.</param>
 /// <param name="innerException">The exception that is the cause of the current exception. If innerException is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
 public PipelineException(
     string message,
     Exception innerException
     )
     :base(message, innerException)
 {
 }
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("ListenerNotFound"))
            {
                return new ListenerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("CertificateNotFound"))
            {
                return new CertificateNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("LoadBalancerNotFound"))
            {
                return new LoadBalancerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidConfigurationRequest"))
            {
                return new InvalidConfigurationRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            return new AmazonElasticLoadBalancingException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
コード例 #17
1
       public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
       {
         ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);                    
         
         if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
         {
           return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("MissingParameterValueException"))
         {
           return new MissingParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
         {
           return new ServiceUnavailableException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValueException"))
         {
           return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         return new AmazonGlacierException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
       }
コード例 #18
1
 protected void ReportError(Exception e)
 {
     if (Errored != null)
     {
         Errored(this, new ErrorEventArgs(e));
     }
 }
コード例 #19
1
        internal static bool CrashIfFailFastEnabled(Exception exception)
        {
            if (!IsFailFastEnabled)
            {
                return false;
            }

            if (exception is NotImplementedException)
            {
                // This is part of the dispatcher mechanism.  A NotImplementedException indicates
                // that another component should handle the call.
                return false;
            }

            var dkmException = exception as DkmException;
            if (dkmException != null)
            {
                switch (dkmException.Code)
                {
                    case DkmExceptionCode.E_PROCESS_DESTROYED:
                    case DkmExceptionCode.E_XAPI_REMOTE_CLOSED:
                    case DkmExceptionCode.E_XAPI_REMOTE_DISCONNECTED:
                    case DkmExceptionCode.E_XAPI_COMPONENT_DLL_NOT_FOUND:
                        return false;
                }
            }

            return FatalError.Report(exception);
        }
コード例 #20
1
		private static ExceptionPolicyImpl GetExceptionPolicy(Exception exception, string policyName)
		{
			try
			{
				return factory.Create(policyName);				
			}
			catch(ConfigurationErrorsException configurationException)
			{
                try
                {
                    DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryFactory.BuildUp<DefaultExceptionHandlingEventLogger>();
                    logger.LogConfigurationError(configurationException, policyName);
                }
                catch { }

                throw;
			}
            catch (Exception ex)
			{
                try
                {
                    string exceptionMessage = ExceptionUtility.FormatExceptionHandlingExceptionMessage(policyName, ex, null, exception);

                    DefaultExceptionHandlingEventLogger logger = EnterpriseLibraryFactory.BuildUp<DefaultExceptionHandlingEventLogger>();
                    logger.LogInternalError(policyName, exceptionMessage);
                }
                catch { }
				
                throw new ExceptionHandlingException(ex.Message, ex);
			}			
		}        
コード例 #21
1
 private void LogException(Exception ex)
 {
     if (MvcApplication.Logger != null)
     {
         MvcApplication.Logger.Error("MyCustomHandleError ", ex);
     }
 }
コード例 #22
1
ファイル: IoOps.cs プロジェクト: ghouston/ironlanguages
 public static Exception/*!*/ NonBlockingError(RubyContext/*!*/ context, Exception/*!*/ exception, bool isRead) {
     RubyModule waitReadable;
     if (context.TryGetModule(isRead ? typeof(WaitReadable) : typeof(WaitWritable), out waitReadable)) {
         ModuleOps.ExtendObject(waitReadable, exception);
     }
     return exception;
 }
コード例 #23
1
        public void End(Exception ex = null)
        {
            if (ex == null)
                sessionFactory.SaveChanges();

            sessionFactory.Dispose();
        }
コード例 #24
1
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
     {
         return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededException"))
     {
         return new LimitExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("OperationAbortedException"))
     {
         return new OperationAbortedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceAlreadyExistsException"))
     {
         return new ResourceAlreadyExistsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
     {
         return new ServiceUnavailableException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCloudWatchLogsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
		public void HandleConnectionError(Exception exception, PluginProfileErrorCollection errors)
		{
			_log.GetLogger("Mercurial").Warn("Check connection failed", exception);
			exception = exception.InnerException ?? exception;
			const string uriFieldName = "Uri";
			if (exception is MercurialExecutionException)
			{
                errors.Add(new PluginProfileError { FieldName = "Login", Message = ExtractValidErrorMessage(exception)});
                errors.Add(new PluginProfileError { FieldName = "Password", Message = ExtractValidErrorMessage(exception) });
                errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = ExtractValidErrorMessage(exception) });
				return;
			}

            if (exception is ArgumentNullException || exception is DirectoryNotFoundException)
			{
				errors.Add(new PluginProfileError{ FieldName = uriFieldName, Message = INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE });
			}

            if (exception is MercurialMissingException)
            {
                errors.Add(new PluginProfileError { Message = MERCURIAL_IS_NOT_INSTALLED_ERROR_MESSAGE });
            }

			var fieldName = string.Empty;
			if (exception is InvalidRevisionException)
			{
				fieldName = "Revision";
			}

			errors.Add(new PluginProfileError {FieldName = fieldName, Message = exception.Message});
		}
コード例 #26
1
ファイル: ErrorMessage.cs プロジェクト: necora/ank_git
        /// <summary>
        /// Sends an error message by opening the user's mail client.
        /// </summary>
        /// <param name="recipient"></param>
        /// <param name="subject"></param>
        /// <param name="ex"></param>
        /// <param name="assembly">The assembly where the error originated. This will 
        /// be used to extract version information.</param>
        public static void SendByMail(string recipient, string subject, Exception ex,
            Assembly assembly, StringDictionary additionalInfo)
        {
            string attributes = GetAttributes(additionalInfo);

            StringBuilder msg = new StringBuilder();

            msg.AppendLine("[ Please send this as plain text to allow automatic pre-processing ]");
            msg.AppendLine();
            msg.AppendLine(GetMessage(ex));
            msg.AppendLine();
            msg.AppendLine(GetAttributes(additionalInfo));
            msg.AppendLine();
            msg.AppendLine("[ Please send this as plain text to allow automatic pre-processing ]");
            msg.AppendLine();

            string command = string.Format("mailto:{0}?subject={1}&body={2}",
                recipient,
                Uri.EscapeDataString(subject),
                Uri.EscapeDataString(msg.ToString()));

            Debug.WriteLine(command);
            Process p = new Process();
            p.StartInfo.FileName = command;
            p.StartInfo.UseShellExecute = true;

            p.Start();
        }
コード例 #27
1
ファイル: ErrorHandlerHelper.cs プロジェクト: JMnITup/SMEX
        //Can only be called inside a service
        public static void PromoteException(Exception error,MessageVersion version,ref Message fault)
        {
            StackFrame frame = new StackFrame(1);

             Type serviceType = frame.GetMethod().ReflectedType;
             PromoteException(serviceType,error,version,ref fault);
        }
コード例 #28
1
        public decimal GetWeeklySalary(string employeeId, int weeks)
        {
            string connString = string.Empty;
              string employeeName = String.Empty;
              decimal salary = 0;
              try
              {
            // Access the database to get the salary for this employee.

            connString = ConfigurationManager.ConnectionStrings
                                  ["EmployeeDatabase"].ConnectionString;
            // ... etc.
            // In this example, just assume it's some large number.
            employeeName = "Jose Lopez";
            salary = 1000000;
            return salary / weeks;
              }
              catch (Exception ex)
              {
            // Provide error information for debugging.
            string template = "Error en el cálculo del salario de {0}. " +
                          "Salario: {1}. Semanas: {2}\n" +
                          "Conexion: {3}\n" +
                          "{4}";
            // Create a new exception to return.
            Exception informationException = new Exception(
              string.Format(template, employeeName, salary, weeks, connString, ex.Message));
            throw informationException;
              }
        }
コード例 #29
1
 public void SyncWebBrowserError(Exception ex)
 {
     InvokeOnMainThread(() => {
         UIAlertView alertView = new UIAlertView("Sync Web Browser Error", ex.Message, null, "OK", null);
         alertView.Show();
     });
 }
コード例 #30
1
        public static double CalculateGeometricSum(double ratio, double firstTerm, int seriesLength, int startTermNumber)
        {
            double sum = 0;
            seriesLength++;
            int nLength = seriesLength - startTermNumber;

            if(ratio == 1)
            {
                Exception ratiois1 = new Exception("The ratio is not allowed to equal 1");
                throw ratiois1;
            }

            if(startTermNumber > 1)
            {
                seriesLength--;
                nLength = seriesLength;
                sum = firstTerm * ((1 - Math.Pow(ratio, nLength)) / (1 - ratio));
                nLength = startTermNumber;
                sum -= firstTerm * ((1 - Math.Pow(ratio, nLength)) / (1 - ratio));
                return sum;
            }

            sum = firstTerm * ((1 - Math.Pow(ratio, nLength)) / (1 - ratio));

            return sum;
        }
コード例 #31
0
 public static bool LoadFromFile(string fileName, out COCD_TP146031UK04SupplyMedicationTemplateId obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
コード例 #32
0
 // Creates a new Exception.  All derived classes should
 // provide this constructor.
 // Note: the stack trace is not started until the exception
 // is thrown
 //
 public Exception(String message, Exception innerException)
 {
     Init();
     _message        = message;
     _innerException = innerException;
 }
コード例 #33
0
 public InvalidCastException(String message, Exception innerException) 
     : base(message, innerException) {
     SetErrorCode(__HResults.COR_E_INVALIDCAST);
 }
コード例 #34
0
 public void OnError(Exception error)
 {
     _onError(error);
 }
コード例 #35
0
ファイル: TimeoutException.cs プロジェクト: wecing/coreclr
 public TimeoutException(String message, Exception innerException)
     : base(message, innerException)
 {
     HResult = HResults.COR_E_TIMEOUT;
 }
コード例 #36
0
 internal static extern void SaveStackTracesFromDeepCopy(Exception exception, object currentStackTrace, object dynamicMethodArray);
コード例 #37
0
 private static extern void GetStackTracesDeepCopy(Exception exception, out object currentStackTrace, out object dynamicMethodArray);
コード例 #38
0
 public SystemException(String message, Exception innerException)
     : base(message, innerException)
 {
     HResult = HResults.COR_E_SYSTEM;
 }
コード例 #39
0
 public UnregisteredAssetException(string message, System.Exception inner) : base(message, inner)
 {
 }
コード例 #40
0
 private static extern bool IsImmutableAgileException(Exception e);
コード例 #41
0
 public static void Exception(System.Exception ex)
 {
     Error(ex.ToString());
 }
コード例 #42
0
 /// <summary>
 /// Creates a new instance of <see cref="ActionException"/>.
 /// </summary>
 /// <param name="action">The action to perform when the exception is caught.</param>
 /// <param name="message">The message that describes the reason for the exception.</param>
 /// <param name="inner">The exception that is the cause of the current exception, or null if no inner exception is specified.</param>
 public ActionException(Action action, string message, Exception inner) : base(message, inner)
 {
     this.Action = action;
 }
コード例 #43
0
 public static bool LoadFromFile(string fileName, out PRPA_MT000002UK03Component27 obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
コード例 #44
0
ファイル: Logging.cs プロジェクト: 06Games/GeneaGrab
 public static void Log(System.Exception e, LogType type = LogType.Exception)
 {
     Log(e.Message, type, e.StackTrace);
 }
コード例 #45
0
 public static bool Deserialize(string xml, out PRPA_MT000002UK03Component27 obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
コード例 #46
0
 /// <summary>
 /// Deserializes workflow markup into an POCD_MT000001UK04Material object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output POCD_MT000001UK04Material object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out POCD_MT000001UK04Material obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(POCD_MT000001UK04Material);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #47
0
 public static bool LoadFromFile(string fileName, out UKCT_MT144044UK01PertinentInformation13 obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
コード例 #48
0
 /// <summary>
 /// Deserializes xml markup from file into an PRPA_MT000002UK03Component27 object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output PRPA_MT000002UK03Component27 object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out PRPA_MT000002UK03Component27 obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(PRPA_MT000002UK03Component27);
     try {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #49
0
 public static bool Deserialize(string xml, out UKCT_MT144044UK01PertinentInformation13 obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
コード例 #50
0
 /// <summary>
 /// Deserializes workflow markup into an PRPA_MT000002UK03Component27 object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output PRPA_MT000002UK03Component27 object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out PRPA_MT000002UK03Component27 obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(PRPA_MT000002UK03Component27);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #51
0
 public void Error(System.Exception exp, string message)
 {
     _logger.Error(exp, message);
 }
コード例 #52
0
 /// <summary>
 /// Deserializes xml markup from file into an UKCT_MT144044UK01PertinentInformation13 object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output UKCT_MT144044UK01PertinentInformation13 object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out UKCT_MT144044UK01PertinentInformation13 obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(UKCT_MT144044UK01PertinentInformation13);
     try {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #53
0
 internal GettingValueExceptionEventArgs(System.Exception exception)
 {
     Exception = exception;
 }
コード例 #54
0
 /// <summary>
 /// Deserializes workflow markup into an UKCT_MT144044UK01PertinentInformation13 object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output UKCT_MT144044UK01PertinentInformation13 object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out UKCT_MT144044UK01PertinentInformation13 obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(UKCT_MT144044UK01PertinentInformation13);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #55
0
 public static bool Deserialize(string xml, out COCD_TP146031UK04SupplyMedicationTemplateId obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
コード例 #56
0
 public void Warn(System.Exception exp, string message)
 {
     _logger.Warn(exp, message);
 }
コード例 #57
0
 /// <summary>
 /// Deserializes xml markup from file into an COCD_TP146031UK04SupplyMedicationTemplateId object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output COCD_TP146031UK04SupplyMedicationTemplateId object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out COCD_TP146031UK04SupplyMedicationTemplateId obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(COCD_TP146031UK04SupplyMedicationTemplateId);
     try {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
コード例 #58
0
 public CreditNoteMailMissing(string message, System.Exception inner) : base(message, inner)
 {
 }
コード例 #59
0
ファイル: Reference.cs プロジェクト: redscarf2/MyProjects
 internal RoleExistsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
     base(exception, cancelled, userState)
 {
     this.results = results;
 }
コード例 #60
0
 /// <summary>
 /// Deserializes workflow markup into an COCD_TP146031UK04SupplyMedicationTemplateId object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output COCD_TP146031UK04SupplyMedicationTemplateId object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out COCD_TP146031UK04SupplyMedicationTemplateId obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(COCD_TP146031UK04SupplyMedicationTemplateId);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }