Improve errors

This commit is contained in:
Bartłomiej Pluta
2019-06-30 20:05:23 +02:00
parent 65353a80f2
commit d0b3a8b3da
8 changed files with 105 additions and 94 deletions

View File

@@ -1,9 +1,10 @@
import sys
from Evaluator import RuntimeException, objectString
from Evaluator import objectString
from Note import *
import random
import Synth
import time
from Error import RuntimeException
types = {
int: 'integer',
@@ -28,7 +29,7 @@ class Environment():
return value
else:
return value
raise RuntimeException(f"Variable '{name}' is not declared" + ("" if type is None else f" (expected type: {types[type]})"))
raise RuntimeException(None, f"Variable '{name}' is not declared" + ("" if type is None else f" (expected type: {types[type]})"))
def findVariableScope(self, name, type=None):
for scope in reversed(self.scopes):