MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Error handling with MathLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37334] Re: Error handling with MathLink
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 24 Oct 2002 02:55:18 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <ap59pr$3r8$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

a) you can manual return the symbol $Failed
   your function should have the ReturnType Manual
   this is typical sufficient when there are not
   more things that can go wrong
b) define a message with Evaluate

   :Evaluate: CFunctions::nomem="foo is out of memory"
   
    and use
    MLEvaluateString(stdlink,"Message[CFunctions::nomem];");

    and clean the link to discard the result
c)  you can return always
    a list {errorCode,functionResult} to Mathematica
    and the Mathematica function generate the messages
    due to the errorCode or return the functionResult

Regards
  Jens
   

"Y.A.Tesiram" wrote:
> 
> G'day all,
> How do I return errors to Mathematica from a MathLink program?
> 
> For e.g.
> 
>         ...
>         ptr = malloc( HUGE_VAL );
>         if (ptr == NULL) {
>                 // How do I return an error value to mathematica here?
>         }
> 
> Thanks
> Yas


  • Prev by Date: Re: Custom colors on a 3-d suface
  • Next by Date: RE: Re: Raising Contour Plot Graphics to 3D
  • Previous by thread: Re: Error handling with MathLink
  • Next by thread: Poincare sections