libocca/occa.py

Pretty print errors given an ast node

Closed this issue · 0 comments

Use the node's col_offset and lineno attributes to print a nice error message for the user

myfile.py:10:30:Error Expected a 1 and not a 0
1234567890123456789012345678901234567890
                             ^

or if in Jupyter, get the cell number and print

In [31]:10:30:Error Expected a 1 and not a 0
1234567890123456789012345678901234567890
                             ^

We might be able to get the cell number with inspect

import inspect
inspect.getfile(foo)
> '<ipython-input-31-5643a48472c0>'