Browse Source

Add WrongStackSizeError class

This error will be thrown whenever an operation is trying to be
performed on N number of elements on the stack, but the stack has < N
elements.
ApisNecros 1 year ago
parent
commit
19fd8fda69
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/errors.ts

+ 6 - 0
src/errors.ts

@@ -28,4 +28,10 @@ export class EmptyStackError extends StarfishError {
     constructor() {
         super("Unable to perform this operation on an empty stack");
     }
+}
+
+export class WrongStackSizeError extends StarfishError {
+    constructor(elementsWanted: number, stackSize: number) {
+        super(`Failed to perform an operation on ${elementsWanted} on a stack with only ${stackSize} elements`);
+    }
 }