Inheritance: System.Exception
示例#1
0
        public void Load(ParsedPath contentPath)
        {
            try
            {
                var node = new TsonParser().Parse(File.ReadAllText(contentPath));

                throw new NotImplementedException();
            }
            catch (Exception e)
            {
                TsonParseException   tpe = e as TsonParseException;
                ContentFileException cfe = e as ContentFileException;

                if (tpe != null)
                {
                    throw new ContentFileException("Bad TSON", tpe);
                }
                else if (cfe != null)
                {
                    throw;
                }
                else
                {
                    throw new ContentFileException(e);
                }
            }
        }
示例#2
0
        public override void Execute()
        {
            try
            {
                if (!NoLogo)
                {
                    Console.WriteLine(Parser.LogoBanner);
                }

                bool hasContentFile = !String.IsNullOrEmpty(ContentPath);

                if ((!hasContentFile && this.Command == "help") ||
                    (String.IsNullOrEmpty(this.Command) && this.ShowHelp))
                {
                    Console.WriteLine(Parser.Usage);
                    return;
                }

                if (!hasContentFile)
                {
                    WriteError("A .content file must be specified");
                    return;
                }

                this.ContentPath = new ParsedFilePath(this.ContentPath.MakeFullPath());

                if (this.Command == "new")
                {
                    CreateContentFileFromTemplate();
                    return;
                }

                if (!File.Exists(this.ContentPath))
                {
                    WriteError("Content file '{0}' does not exist", this.ContentPath);
                    return;
                }

                buildContext = new BuildContext(this.Properties, this.ContentPath);

                ApplyCompilerSettingsExtensions();

                if (this.Command == "help")
                {
                    WriteContentCompilerUsage();
                    return;
                }

                List <BuildTarget> buildTargets;

                PrepareBuildTargets(out buildTargets);

                if (this.Command == "clean")
                {
                    Clean(buildTargets);
                }
                else
                {
                    Build(buildTargets);
                }

                WriteMessage("Done");
            }
            catch (Exception e)
            {
                TextLocation?mark = null;

                do
                {
                    ContentFileException cfe = e as ContentFileException;
                    TsonParseException   tpe = e as TsonParseException;

                    if (cfe != null)
                    {
                        mark = cfe.ErrorLocation;
                    }
                    else if (tpe != null)
                    {
                        mark = tpe.ErrorLocation;
                    }

                    // If we started showing content file errors, keep going...
                    if (mark.HasValue)
                    {
                        WriteErrorWithLine(ContentPath, mark.Value.Line + 1, mark.Value.Column + 1, e.Message);
                    }
                    else
                    {
                        ConsoleUtility.WriteMessage(MessageType.Error, e.Message);
                    }
#if DEBUG
                    // Gotta have this in debug builds
                    Console.WriteLine(e.StackTrace);
#endif
                }while ((e = e.InnerException) != null);
            }
        }