/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0-alpha-1
src/OneScript.Language/ScriptException.cs
83 строки
2 KB
Andrey Ovsiankin
Полностью переделана работа с типами (начало).
26 янв 2021, 17:56
26 янв 2021, 17:56
5d1c262
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; using System.Text; namespace OneScript.Language { public class ScriptException : ApplicationException { private readonly ErrorPositionInfo _codePosition; public ScriptException() { _codePosition = new ErrorPositionInfo(); _codePosition.LineNumber = -1; } public ScriptException(string message) : this(new ErrorPositionInfo(), message, null) { } public ScriptException(ErrorPositionInfo errorInfo, string message, Exception innerException = null) : base(message, innerException) { _codePosition = errorInfo ?? throw new ArgumentNullException(nameof(errorInfo)); } public int LineNumber { get => _codePosition.LineNumber; set => _codePosition.LineNumber = value; } public int ColumnNumber { get => _codePosition.ColumnNumber; set => _codePosition.ColumnNumber = value; } public string Code { get => _codePosition.Code; set => _codePosition.Code = value; } public string ModuleName { get => _codePosition.ModuleName; set => _codePosition.ModuleName = value; } public string ErrorDescription => base.Message; public string MessageWithoutCodeFragment { get { if (ColumnNumber != ErrorPositionInfo.OUT_OF_TEXT) return $"{{Модуль {ModuleName} / Ошибка в строке: {LineNumber},{ColumnNumber} / {base.Message}}}"; return $"{{Модуль {ModuleName} / Ошибка в строке: {LineNumber} / {base.Message}}}"; } } public override string Message { get { var sb = new StringBuilder(MessageWithoutCodeFragment); sb.AppendLine(" "); sb.Append(Code); return sb.ToString(); } } } }