diff --git a/extra/python/errors/errors.factor b/extra/python/errors/errors.factor index c60b155ccb..6325929f6f 100644 --- a/extra/python/errors/errors.factor +++ b/extra/python/errors/errors.factor @@ -1,16 +1,14 @@ -USING: alien.c-types alien.data kernel python.ffi ; +USING: alien.c-types alien.data kernel python.ffi vocabs.loader words ; IN: python.errors -ERROR: python-error type message ; - diff --git a/extra/python/throwing/throwing.factor b/extra/python/throwing/throwing.factor new file mode 100644 index 0000000000..f18aedfff7 --- /dev/null +++ b/extra/python/throwing/throwing.factor @@ -0,0 +1,14 @@ +USING: arrays kernel python python.syntax sequences ; +IN: python.throwing + +ERROR: python-error type message traceback ; + +PY-FROM: traceback => format_tb ( tb -- seq ) ; + +PY-METHODS: obj => + __name__ ( o -- str ) + __str__ ( o -- str ) ; + +: throw-error ( ptype pvalue ptraceback -- ) + [ $__name__ py> ] [ __str__ py> ] [ [ format_tb py> ] [ f ] if* ] tri* + python-error ;