help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Message Id for undefined function


From: Max Brister
Subject: Re: Message Id for undefined function
Date: Tue, 3 Jul 2012 09:38:30 -0500

On Tue, Jul 3, 2012 at 9:13 AM, Juan Pablo Carbajal <address@hidden> wrote:
> On Fri, Jun 22, 2012 at 5:26 PM, Juan Pablo Carbajal
> <address@hidden> wrote:
>> Hi all,
>>
>> I just realized that there is no message ID when a function is not
>> found in the current path. Example
>>
>> octave:184> my_function_loca  % This function doesn't exist
>> error: `my_function_loca' undefined near line 184 column 1
>> octave:184> [msg id] = lasterr
>> msg = `my_function_loca' undefined near line 184 column 1
>> id =
>>
>> I am trying to write a try-catch block that catches that error. What can I 
>> do?
>>
>> Thanks
>>
>> --
>> M. Sc. Juan Pablo Carbajal
>> -----
>> PhD Student
>> University of Zürich
>> http://ailab.ifi.uzh.ch/carbajal/
>
> Pinging this question. Any comments?
>
>
> --
> M. Sc. Juan Pablo Carbajal
> -----
> PhD Student
> University of Zürich
> http://ailab.ifi.uzh.ch/carbajal/
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

You could use a regular expression to check the message text, for example

try
  # code here
catch
  msg = lasterr;
  if regexp (msg, "undefined near line [0-9]+ column [0-9]+$")
    # something was undefined
  else
    rethrow (lasterror);
  endif
end

This solution is not pretty and may break between Octave versions. I
think the best solution is to add an error id in Octave.

Max Brister


reply via email to

[Prev in Thread] Current Thread [Next in Thread]