Emit errors on stderr.
This commit is contained in:
parent
de774af3da
commit
3d78f831cb
|
|
@ -55,6 +55,7 @@ Ulam Spiral).
|
||||||
'''
|
'''
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from inspect import getdoc
|
from inspect import getdoc
|
||||||
|
from sys import stderr
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
|
|
@ -470,7 +471,7 @@ def hack_error_message(exception):
|
||||||
message = message[0].swapcase() + message[1:]
|
message = message[0].swapcase() + message[1:]
|
||||||
if '.' != message[-1]:
|
if '.' != message[-1]:
|
||||||
message += '.'
|
message += '.'
|
||||||
print(message)
|
print(message, file=stderr)
|
||||||
|
|
||||||
|
|
||||||
def repl(stack=(), dictionary=None):
|
def repl(stack=(), dictionary=None):
|
||||||
|
|
@ -495,7 +496,7 @@ def repl(stack=(), dictionary=None):
|
||||||
try:
|
try:
|
||||||
stack, dictionary = run(text, stack, dictionary)
|
stack, dictionary = run(text, stack, dictionary)
|
||||||
except UnknownSymbolError as sym:
|
except UnknownSymbolError as sym:
|
||||||
print('Unknown:', sym)
|
print('Unknown:', sym, file=stderr)
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
raise SystemExit from e
|
raise SystemExit from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -537,14 +538,14 @@ def interp(stack=(), dictionary=None):
|
||||||
try:
|
try:
|
||||||
stack, dictionary = run(text, stack, dictionary)
|
stack, dictionary = run(text, stack, dictionary)
|
||||||
except UnknownSymbolError as sym:
|
except UnknownSymbolError as sym:
|
||||||
print('Unknown:', sym)
|
print('Unknown:', sym, file=stderr)
|
||||||
except (
|
except (
|
||||||
StackUnderflowError,
|
StackUnderflowError,
|
||||||
NotABoolError,
|
NotABoolError,
|
||||||
NotAListError,
|
NotAListError,
|
||||||
NotAnIntError,
|
NotAnIntError,
|
||||||
) as e:
|
) as e:
|
||||||
print(e)
|
print(e, file=stderr)
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
raise SystemExit from e
|
raise SystemExit from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue