SWI-Prolog / packages-mqi

Machine Query Interface
18 stars 5 forks source link

Need to find a way to return second argument of exceptions like error/2 #9

Open EricZinda opened 2 years ago

EricZinda commented 2 years ago

Currently an exception like error(type_error(callable,1),context(textProgram/5,_987478)) in Prolog will be returned to Python as exception(type_error(callable,1)) since I have found the second argument often contains objects that can't be serialized over the wire. Currently the second argument is just removed, always.

Instead the language_server code should attempt to serialize the argument and, if it succeeds, send it. Only if it can't be it should be stripped. This is because the second argument often provides key context for where the error occurred (as in the above example) and without it, the user needs to go into standalone mode to figure out what the issue is.