Re: trying to catch exception

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed, 26 Jan 2005 10:40:32 -0700

Hi John,

You can check the value of wks after the Ngl.open_wks call. If
it's less than 0, you know it did not succeed, and you can prevent
the later calls that result in the segfault.

In this case the first set of error messages will still appear.

Another possibility is to check the DISPLAY environment variable
before calling Ngl.open_wks. If it's not set then X is not running,
although
I suppose the fact that it is set does not prove that X is running.
  -dave

On Jan 26, 2005, at 7:57 AM, Ertl, John wrote:

>
> All,
>
> I have program that uses an x11 window to view plots if the user wants
> to
> but some people do not have a system that allows an x11 window. I am
> trying
> to gracfull continue the program and display an error message instead
> of
> crashing when this happens.
>
> I have tried the below try statment and some other stuff but no luck.
> Any
> ideas.
>
> def view(self,whatToView="c"):
> #### Uses PyNGL to view grid.
> try:
> wks = Ngl.open_wks("x11","job.test",None)
> except:
> return
>
>
> -error from the above try...it does not get caught.
> warning:GKS:GOPWK: --X driver error: DISPLAY environment variable not
> set
> warning:GKS:GESC: --SPECIFIED WORKSTATION IS NOT OPEN
> fatal:Workstation with PID#7 is not open
> fatal:Unable to open Workstation-Can't Create
>
> -error from further down in function
> fatal:PID #-4 can't be found in NhlSetValues
> fatal:_NhlCreate:Invalid Parent id #-4
> fatal:NhlGetValues:PID #-4 is invalid
> fatal:NhlGetValues:PID #-4 is invalid
> Segmentation fault
>
> Thanks for the help.
>
> John
> _______________________________________________
> pyngl-talk mailing list
> pyngl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Wed Jan 26 2005 - 10:40:32 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:31:52 MST