mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor: move JsonModelExt to PluralKit.Core (in individual model/patch files)
This commit is contained in:
parent
26c18d2f48
commit
11bd66e8d8
9 changed files with 193 additions and 186 deletions
19
PluralKit.Core/Utils/JsonUtils.cs
Normal file
19
PluralKit.Core/Utils/JsonUtils.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
internal static class JsonUtils
|
||||
{
|
||||
public static string BoundsCheckField(this string input, int maxLength, string nameInError)
|
||||
{
|
||||
if (input != null && input.Length > maxLength)
|
||||
throw new JsonModelParseError($"{nameInError} too long ({input.Length} > {maxLength}).");
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
public class JsonModelParseError: Exception
|
||||
{
|
||||
public JsonModelParseError(string message): base(message) { }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue