refactor: rename MaxLengthException & fix naming

This commit is contained in:
ZavaruKitsu 2022-10-15 21:59:12 +03:00
parent fb51677429
commit 9400cfc74e
6 changed files with 33 additions and 30 deletions

View File

@ -8,22 +8,22 @@ namespace TelegramBotBase.DataSources;
public class ButtonFormDataSource : IDataSource<ButtonRow>
{
private ButtonForm _buttonform;
private ButtonForm _buttonForm;
public ButtonFormDataSource()
{
_buttonform = new ButtonForm();
_buttonForm = new ButtonForm();
}
public ButtonFormDataSource(ButtonForm bf)
{
_buttonform = bf;
_buttonForm = bf;
}
public virtual ButtonForm ButtonForm
{
get => _buttonform;
set => _buttonform = value;
get => _buttonForm;
set => _buttonForm = value;
}

View File

@ -1,11 +0,0 @@
using System;
namespace TelegramBotBase.Exceptions;
public class MaxLengthException : Exception
{
public MaxLengthException(int length) : base(
$"Your messages with a length of {length} is too long for telegram. Actually is {Constants.Telegram.MaxMessageLength} characters allowed. Please split it.")
{
}
}

View File

@ -2,13 +2,11 @@
namespace TelegramBotBase.Exceptions;
public class MaximumColsException : Exception
public sealed class MaximumColsException : Exception
{
public int Value { get; set; }
public int Maximum { get; set; }
public override string Message =>
$"You have exceeded the maximum of columns by {Value.ToString()} / {Maximum.ToString()}";
}
$"You have exceeded the maximum of columns by {Value}/{Maximum}";
}

View File

@ -2,7 +2,7 @@
namespace TelegramBotBase.Exceptions;
public class MaximumRowsReachedException : Exception
public sealed class MaximumRowsReachedException : Exception
{
public int Value { get; set; }
@ -10,5 +10,5 @@ public class MaximumRowsReachedException : Exception
public override string Message =>
$"You have exceeded the maximum of rows by {Value.ToString()} / {Maximum.ToString()}";
}
$"You have exceeded the maximum of rows by {Value}/{Maximum}";
}

View File

@ -0,0 +1,16 @@
using System;
namespace TelegramBotBase.Exceptions;
public sealed class MessageTooLongException : Exception
{
public MessageTooLongException(int length)
{
Length = length;
}
public int Length { get; set; }
public override string Message =>
$"You have exceeded the maximum of message length by {Length}/{Constants.Telegram.MaxMessageLength}";
}

View File

@ -155,7 +155,7 @@ public class DeviceSession : IDeviceSession
if (text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(text.Length);
throw new MessageTooLongException(text.Length);
}
try
@ -183,7 +183,7 @@ public class DeviceSession : IDeviceSession
{
if (text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(text.Length);
throw new MessageTooLongException(text.Length);
}
try
@ -213,7 +213,7 @@ public class DeviceSession : IDeviceSession
if (message.Text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(message.Text.Length);
throw new MessageTooLongException(message.Text.Length);
}
try
@ -270,7 +270,7 @@ public class DeviceSession : IDeviceSession
if (text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(text.Length);
throw new MessageTooLongException(text.Length);
}
if (parseMode == ParseMode.MarkdownV2 && markdownV2AutoEscape)
@ -329,7 +329,7 @@ public class DeviceSession : IDeviceSession
if (text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(text.Length);
throw new MessageTooLongException(text.Length);
}
if (parseMode == ParseMode.MarkdownV2 && markdownV2AutoEscape)
@ -372,7 +372,7 @@ public class DeviceSession : IDeviceSession
if (text.Length > Constants.Telegram.MaxMessageLength)
{
throw new MaxLengthException(text.Length);
throw new MessageTooLongException(text.Length);
}
if (parseMode == ParseMode.MarkdownV2 && markdownV2AutoEscape)