This instance will be upgraded to the latest Heptapod 0.20rc on 2021-02-26 at 11:00 UTC+1

AssemblerError.cs 1.55 KB
Newer Older
1
/* Copyright 2010-2018 Jesse McGrew
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * 
 * This file is part of ZILF.
 * 
 * ZILF is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ZILF is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ZILF.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Runtime.Serialization;

namespace Zapf.Parsing.Diagnostics
{
    [Serializable]
    public abstract class AssemblerError : Exception
    {
27
        protected AssemblerError(ISourceLine? node, string message)
28 29 30 31 32
            : base(message)
        {
            Node = node;
        }

33
        protected AssemblerError(SerializationInfo info, StreamingContext context)
34 35 36 37 38
            : base(info, context)
        {
            Node = (ISourceLine)info.GetValue("node", typeof(ISourceLine));
        }

39
        public ISourceLine? Node { get; }
40 41 42 43 44 45 46 47 48 49 50 51

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);

            if (Node != null)
            {
                info.AddValue("node", Node);
            }
        }
    }
}