Exemplo n.º 1
0
        /// <summary>
        /// Throw this PlException.
        /// </summary>
        /// <remarks>see <see href="http://www.swi-prolog.org/packages/pl2cpp.html#cppThrow()"/></remarks>
        public void Throw()
        {
            // term_t
            uintptr_t a = LibPl.PL_new_term_ref();
            // atom_t
            uintptr_t name  = 0;
            int       arity = 0;

            if (0 != LibPl.PL_get_arg(1, _exTerm.TermRef, a) && 0 != LibPl.PL_get_name_arity(a, ref name, ref arity))
            {
                string str = LibPl.PL_atom_wchars(name);

                if (str == "type_error")
                {
                    throw new PlTypeException(_exTerm);
                }
                if (str == "domain_error")
                {
                    throw new PlDomainException(_exTerm);
                }
            }
            _messagePl = Message;
            throw this;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Generate an exception (as throw/1) and return <c>false</c>.
 /// </summary>
 /// <remarks>Used in the PREDICATE() wrapper to pass the exception to Prolog. See PL_raise_exeption().</remarks>
 /// <returns>Generate an exception (as throw/1) and return <c>false</c>.</returns>
 public bool PlThrow()
 {
     return(LibPl.PL_raise_exception(_exTerm.TermRef) == 1);
 }