The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 18th, 2024, 10:24am
Pages: 1
Send Topic Print
exception handling in OCEAN (Read 2477 times)
analogue_guy
Community Member
***
Offline



Posts: 38

exception handling in OCEAN
May 08th, 2009, 11:38am
 
Hi all,

Do you know how to make exception handling in Ocean?
If Calculator expressions, due to a reason, fail  (they result in NaN) usually stop the whole execution of the OCEAN script.
Any solution for that?

cheers

--AG
Back to top
 
 
View Profile   IP Logged
pancho_hideboo
Senior Fellow
******
Offline



Posts: 1424
Real Homeless
Re: exception handling in OCEAN
Reply #1 - May 8th, 2009, 9:44pm
 
Use "loadi()" instead of "load()".
Back to top
 
 
View Profile WWW Top+Secret Top+Secret   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: exception handling in OCEAN
Reply #2 - May 29th, 2009, 1:29am
 
The best solution is to check for return values of functions - for example, check that a data access function returned a value rather than nil - before using it in an expression.

That way you can handle errors gracefully rather than just causing an expression to fail. For example:

Code:
when(out=v("/out" ?result 'tran)
  fft=dft(out ...)
) 



or:

Code:
if(out=v("/out" ?result 'tran) then
  fft=dft(out ...)
else
  printf("Transient analysis failed\n")
) 



If for example the transient didn't run for some reason, v() will return nil, and so it won't try and do the dft on nil.

loadi() is one approach, but it's messy and doesn't really allow you to gracefully handle the errors.

Best Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.