/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/OneScript.Core/Exceptions/RuntimeException.cs
210 строк
8 KB
Dmitry Ivanov
Поддержка потока в ЗаписьТекста
19 дек 2025, 00:03
19 дек 2025, 00:03
cebce69
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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 OneScript.Localization; namespace OneScript.Exceptions { public class RuntimeException : BslCoreException { public RuntimeException(BilingualString message, Exception innerException) : base(message, innerException) { } public RuntimeException(BilingualString message) : base(message) { } public RuntimeException(string message_ru, string message_en) : base(new BilingualString(message_ru, message_en)) { } #region Static Factory Methods public static RuntimeException DeprecatedMethodCall(string name) { return new RuntimeException( $"Вызов безнадёжно устаревшего метода {name}", $"Call to deprecated method {name}"); } public static RuntimeException DeprecatedPropertyAccess(string name) { return new RuntimeException( $"Обращение к безнадёжно устаревшему свойству {name}", $"Access to deprecated property {name}"); } public static RuntimeException MethodNotFoundException(string methodName) { return new RuntimeException( $"Метод объекта не обнаружен ({methodName})", $"Method not found ({methodName})"); } public static RuntimeException MethodNotFoundException(string methodName, string objectName) { return new RuntimeException( $"Метод объекта не обнаружен ({{{objectName}}}::{methodName})", $"Method not found ({{{objectName}}}::{methodName})"); } public static RuntimeException TooManyArgumentsPassed() { return new RuntimeException( "Слишком много фактических параметров", "Too many arguments were passed"); } public static RuntimeException TooFewArgumentsPassed() { return new RuntimeException( "Недостаточно фактических параметров", "Too few arguments were passed"); } public static RuntimeException MissedArgument() { return new RuntimeException( "Пропущен обязательный параметр", "Missed mandatory argument"); } public static RuntimeException InvalidArgumentType() { return new RuntimeException( "Неверный тип аргумента", "Invalid type of argument"); } public static RuntimeException InvalidArgumentType(string argName) { return new RuntimeException( $"Неверный тип аргумента '{argName}'", $"Invalid type of argument '{argName}'"); } public static RuntimeException InvalidArgumentType(int argNum, string argName) { return new RuntimeException( $"Неверный тип аргумента номер {argNum} '{argName}'", $"Invalid type of argument number {argNum} '{argName}'"); } public static RuntimeException InvalidNthArgumentType(int argNum) { return new RuntimeException( $"Неверный тип аргумента номер {argNum}", $"Invalid type of argument number {argNum}"); } public static RuntimeException InvalidArgumentValue() { return new RuntimeException( "Неверное значение аргумента", "Invalid argument value"); } public static RuntimeException InvalidArgumentValue(object value) { return new RuntimeException( $"Неверное значение аргумента {value}", $"Invalid value for argument {value}"); } public static RuntimeException InvalidNthArgumentValue(int argNum) { return new RuntimeException( $"Неверное значение аргумента номер {argNum}", $"Invalid value for argument number {argNum}"); } public static RuntimeException IndexedAccessIsNotSupportedException() { return new RuntimeException( "Объект не поддерживает доступ по индексу", "Indexed access is not supported"); } public static RuntimeException IteratorIsNotDefined() { return new RuntimeException("Итератор не определен","Iterator is not defined"); } public static RuntimeException UseProcAsAFunction() { return new RuntimeException( "Использование процедуры как функции", "Procedure called as function"); } public static RuntimeException DivideByZero() { return new RuntimeException("Деление на ноль", "Divide by zero"); } public static RuntimeException ConstructorNotFound(string typeName) { return new RuntimeException( $"Конструктор не найден ({typeName})", $"Constructor not found ({typeName})"); } public static RuntimeException TypeIsNotDefined(string typeName) { return new RuntimeException( $"Тип не определен. Конструктор не найден ({typeName})", // для совместимости с v1 $"Type is not defined ({typeName})"); } public static RuntimeException TypeIsNotRegistered(string typeName) { return new RuntimeException( $"Тип не зарегистрирован ({typeName})", $"Type is not registered ({typeName})"); } public static RuntimeException InvalidEncoding(string encoding) { return new RuntimeException( $"Неправильное имя кодировки '{encoding}'", $"Invalid encoding name '{encoding}'"); } public static RuntimeException IncorrectOffset() { return new RuntimeException( "Неправильное смещение внутри коллекции", "Incorrect offset within collection"); } public static RuntimeException IndexOutOfRange() { return new RuntimeException( "Значение индекса выходит за пределы диапазона", "Index is out of range"); } public static RuntimeException ClosedStream() { return new RuntimeException( "Ошибка обращения к закрытому потоку", "Cannot access a closed stream"); } public static RuntimeException NonWritableStream() { return new RuntimeException( "Попытка записи в поток не поддерживающий запись", "Cannot write to a stream that does not support writing"); } #endregion } }