diff --git a/joy/library.py b/joy/library.py index 6e7f817..8bd38f1 100644 --- a/joy/library.py +++ b/joy/library.py @@ -222,7 +222,7 @@ def BinaryBuiltinWrapper(f): try: (a, (b, stack)) = stack except ValueError: - raise StackUnderflowError + raise StackUnderflowError('Not enough values on stack.') if (not isinstance(a, int) or not isinstance(b, int) or isinstance(a, bool) # Because bools are ints in Python. @@ -849,7 +849,7 @@ def i(stack, expression, dictionary): try: quote, stack = stack except ValueError: - raise StackUnderflowError + raise StackUnderflowError('Not enough values on stack.') return stack, concat(quote, expression), dictionary @@ -1174,7 +1174,7 @@ def dip(stack, expression, dictionary): try: (quote, (x, stack)) = stack except ValueError: - raise StackUnderflowError + raise StackUnderflowError('Not enough values on stack.') expression = (x, expression) return stack, concat(quote, expression), dictionary @@ -1378,13 +1378,13 @@ def loop(stack, expression, dictionary): try: quote, stack = stack except ValueError: - raise StackUnderflowError + raise StackUnderflowError('Not enough values on stack.') if not isinstance(quote, tuple): raise NotAListError('Loop body not a list.') try: (flag, stack) = stack except ValueError: - raise StackUnderflowError + raise StackUnderflowError('Not enough values on stack.') if flag: expression = concat(quote, (quote, (S_loop, expression))) return stack, expression, dictionary diff --git a/joy/utils/generated_library.py b/joy/utils/generated_library.py index 071cce4..2e51422 100644 --- a/joy/utils/generated_library.py +++ b/joy/utils/generated_library.py @@ -67,10 +67,10 @@ def cons(stack): """ try: s0, stack = stack - except ValueError: raise StackUnderflowError - if not isinstance(s0, tuple): raise NotAListError + except ValueError: raise StackUnderflowError('Not enough values on stack.') + if not isinstance(s0, tuple): raise NotAListError('Not a list.') try: a1, s23 = stack - except ValueError: raise StackUnderflowError + except ValueError: raise StackUnderflowError('Not enough values on stack.') return ((a1, s0), s23) diff --git a/joy/utils/stack.py b/joy/utils/stack.py index c460384..366d8a4 100644 --- a/joy/utils/stack.py +++ b/joy/utils/stack.py @@ -177,7 +177,7 @@ def concat(quote, expression): temp = [] while quote: if not isinstance(quote, tuple): - raise NotAListError + raise NotAListError('Not a list.') item, quote = quote temp.append(item) for item in reversed(temp):