Пример #1
0
        public static void Fail(AppError.ErrorCode errorCode, string message = null)
        {
            var err = new AppError(errorCode, message);

            err.Report();
            err.Fail();
        }
Пример #2
0
        public static void Main(string[] args)
        {
            bool debug = false;
            bool help  = false;

            #if !NOCATCH
            try {
            #endif

            new OptionSet()
            {
                { "debug", _ => debug = true },
                { "?|help", _ => help = true },
            }.Parse(args);

            if (!help)
            {
                Run(args);
            }
            else
            {
                ShowHelp();
            }

            #if !NOCATCH
        }

        catch (AppError e) {
            e.Report(debug);
            e.Fail();
        } catch (Exception e) {
            var err = new AppError(AppError.ErrorCode.UnknownError, e.Message);
            err.Report();
            if (debug)
            {
                Console.WriteLine(e.StackTrace);
            }
            err.Fail();
        }
            #endif
        }