More moves implemented
This commit is contained in:
		
							
								
								
									
										25
									
								
								PkmnLib.Static/Utils/Errors/OutOfRangeException.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								PkmnLib.Static/Utils/Errors/OutOfRangeException.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
|  | ||||
| namespace PkmnLib.Static.Utils.Errors; | ||||
|  | ||||
| /// <summary> | ||||
| /// A result that indicates an index is out of range. | ||||
| /// </summary> | ||||
| public class OutOfRangeException : Exception | ||||
| { | ||||
|     private readonly string _hint; | ||||
|     private readonly int _index; | ||||
|     private readonly int _max; | ||||
|  | ||||
|     /// <inheritdoc cref="OutOfRangeException"/> | ||||
|     public OutOfRangeException(string hint, int index, int max) | ||||
|     { | ||||
|         _hint = hint; | ||||
|         _index = index; | ||||
|         _max = max; | ||||
|     } | ||||
|  | ||||
|     /// <inheritdoc /> | ||||
|     public override string Message => _max == 0 | ||||
|         ? $"{_hint} index {_index} is out of range. Collection is empty." | ||||
|         : $"{_hint} index {_index} is out of range. Must be between 0 and {_max - 1}."; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user