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.
@@ -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`);
+ }