|
| 1 | +// _ __ __ |
| 2 | +// ___ ___ ___ _ __ __| | __ _ | \/ | |
| 3 | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | |
| 4 | +// \__ \\__ \| __/| | | || (_| || (_| || | | | |
| 5 | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| |
| 6 | +// | |
| 7 | +// Copyright 2021-2022 Łukasz "JustArchi" Domeradzki |
| 8 | +// Contact: JustArchi@JustArchi.net |
| 9 | +// | |
| 10 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | +// you may not use this file except in compliance with the License. |
| 12 | +// You may obtain a copy of the License at |
| 13 | +// | |
| 14 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | +// | |
| 16 | +// Unless required by applicable law or agreed to in writing, software |
| 17 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | +// See the License for the specific language governing permissions and |
| 20 | +// limitations under the License. |
| 21 | + |
| 22 | +using System; |
| 23 | +using JetBrains.Annotations; |
| 24 | +using JustArchiNET.Madness.Helpers; |
| 25 | +using JustArchiNET.Madness.Internal; |
| 26 | + |
| 27 | +namespace JustArchiNET.Madness.ArgumentExceptionMadness; |
| 28 | + |
| 29 | +[MadnessType(EMadnessType.Replacement)] |
| 30 | +[PublicAPI] |
| 31 | +public class ArgumentException : System.ArgumentException { |
| 32 | + [MadnessType(EMadnessType.Proxy)] |
| 33 | + public ArgumentException(string message, string paramName) : base(message, paramName) { } |
| 34 | + |
| 35 | + [MadnessType(EMadnessType.Proxy)] |
| 36 | + public ArgumentException(string message, string paramName, Exception innerException) : base(message, paramName, innerException) { } |
| 37 | + |
| 38 | + [MadnessType(EMadnessType.Proxy)] |
| 39 | + public ArgumentException(string message, Exception innerException) : base(message, innerException) { } |
| 40 | + |
| 41 | + [MadnessType(EMadnessType.Proxy)] |
| 42 | + public ArgumentException(string message) : base(message) { } |
| 43 | + |
| 44 | + [MadnessType(EMadnessType.Proxy)] |
| 45 | + public ArgumentException() { } |
| 46 | + |
| 47 | + [MadnessType(EMadnessType.Implementation)] |
| 48 | + public static void ThrowIfNullOrEmpty( |
| 49 | + [ValidatedNotNull] |
| 50 | + |
| 51 | +#if NETSTANDARD2_1_OR_GREATER |
| 52 | + [System.Diagnostics.CodeAnalysis.NotNull] |
| 53 | +#endif |
| 54 | + |
| 55 | + string? argument, string? paramName = null |
| 56 | + ) { |
| 57 | + if (string.IsNullOrEmpty(argument)) { |
| 58 | + JustArchiNET.Madness.ArgumentNullExceptionMadness.ArgumentNullException.ThrowIfNull(argument, paramName); |
| 59 | + |
| 60 | + if (paramName != null) { |
| 61 | + throw new ArgumentException(string.Empty, paramName); |
| 62 | + } |
| 63 | + |
| 64 | + throw new ArgumentNullException(); |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments