Re: Catching messages
- To: mathgroup at smc.vnet.net
- Subject: [mg91620] Re: Catching messages
- From: thorgal <pbruynd at vub.ac.be>
- Date: Fri, 29 Aug 2008 04:24:59 -0400 (EDT)
- References: <g90bg1$n91$1@smc.vnet.net> <g95k03$4tr$1@smc.vnet.net>
On Aug 28, 9:26 am, David Bailey <dave at Remove_Thisdbailey.co.uk> wrote: > thorgalwrote: > > Is there an easy way to immediately abort a function that was called > > when it generates a given message and return to the part of the > > program that called this function ? I want to do this when I call > > some function from Mathematica packages, i.e. i don't want to change > > to function code in the packages and include e.g. catch-throw > > sequences. > > I don't think your request is very meaningful as stated. When you call a > function - even some built-in ones - that function may make several > sub-calls before the diagnostic is generated. Falling back one level > (which is more or less what happens anyway after the diagnostic has been > generated) is not really useful, and tends to result in a cascade of > errors. > > Why not tell us a bit more about what you are trying to achieve. For > example, if you are trying to do something like a minimisation (where > the package contains the minimation code), and the function can > misbehave for some values, wrap the function in another which catches > the errors and returns a suitable numeric value in these cases. > > David Baileyhttp://www.dbaileyconsultancy.co.uk David, It is indeed something like you suggested. I am using the Wolfram Neural network package. Sometimes it happens that the algorithm has problems, converges slowly or other warnings. Usually it is sufficient to stop the training, re-initialize the neural network and train again. Now I do this manually and I would like to find a way that the neural network training function I call from my program would return to my program when a given warning message is issued, i.e so not just falling back one level, but falling back to the level where my program called the training function , so that the program can re- initialize the network and try again. I haven't found any Mathematica command that can force a program to return to a given level when an error/warning occurs at a deeper level.