Handling Exceptions in Visual Basic

If an exception has been raised during Prolog execution, the functions PrologQueryCutFail or PrologNextSolution return -1. To access the exception term, the procedure PrologGetException can be used. This procedure will deposit the exception term in string format into an output parameter, as if written via the writeq/2 predicate.

Example: when the following code fragment is executed, the message box will display the domain_error(_1268 is 1+a,2,expression,a) error string.

        Dim exc As String
     
        qid = PrologOpenQuery("X is 1+a")
        If PrologNextSolution(qid) < 0 Then
           PrologGetException(exc)
           Msg exc,48,"Error"
        End if