_Samples/Example_Exceptions.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Data.Common;
using System.Security.Cryptography;

using ComLib.Entities;
using ComLib.Account;
using ComLib;
using ComLib.Application;
using ComLib.Exceptions;


namespace ComLib.Samples
{
    /// <summary>
    /// Example for the Exceptions namespace.
    /// </summary>
    public class Example_Exceptions : App
    {
        /// <summary>
        /// Initialize.
        /// </summary>
        public Example_Exceptions()
        {
        }


        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem Execute()
        {
            ErrorManager.Register("myErrorManager", false, new CustomExceptionHandler("myErrorManager"));
            Console.WriteLine("====================================================");
            Console.WriteLine("EXCEPTION HANDLING ");

            try
            {
                throw new ArgumentException("exception handling testing");
            }
            catch (Exception ex)
            {
                // Option 1. Use default error handler.
                ErrorManager.Handle("Default error handling.", ex);

                // Option 2. Use custom named error handler "myErrorManager"
                ErrorManager.Handle("Example with custom NAMED error handler.", ex, "myErrorManager");
            }
            Console.WriteLine(Environment.NewLine);
            return BoolMessageItem.True;
        }


        class CustomExceptionHandler : ErrorManagerBase
        {
            public CustomExceptionHandler(string name)
后面还有 13 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。