POV-Ray : Newsgroups : povray.unofficial.patches : Error handling during parsing Server Time
4 Nov 2024 16:06:38 EST (-0500)
  Error handling during parsing (Message 1 to 8 of 8)  
From: Peter Popov
Subject: Error handling during parsing
Date: 17 Dec 2003 05:07:12
Message: <vu90uv8qe10h1kfnf0ho8ipt3voq1i1p19@4ax.com>
How hard would it be, and would it make any sense, to implement some
sort of error handling for parse-time errors? For example:

sphere {
  0, 1
  pigment {
    image_map {
      #try png "image1.png"
      #else png "image2.png"
      #end
      interpolate 2
      map_type 1
    }
  }
}

I'm not proposing this syntax, of course (yuck), but the idea is more
or less clear. Parsing goes on as normal but if a parsing error is
generated in a specified block, something else can be said to happen
instead of just aborting.

Probably the only thing this is potentially useful for is for file
operations (#include, #fopen, image_map, density_file, bump_map,
texture_map etc.) Things like division by zero, input out of range,
array range check failure etc. can be handled manually with proper
programming, but for file operations there is currently no way. I
guess it would be simpler to implement an #if_exists or similar not so
horrible keyword that can check if a file exists in the Library_path
but a more general error handling mechanism, if implemented properly,
could make things easier even in cases where it is not the only
option.

What do you guys think?


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Nicolas Calimet
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 06:30:11
Message: <3fe03e43$1@news.povray.org>
> What do you guys think?

	Can't you check whether a file exists or not with an INI
Pre_Frame_Command  command, which then creates a copy or link to
this file using a generic filename, and use this generic filename
in your POV script ?  I guess something similar is done in some
ini files (ini/ directory).

	- NC


Post a reply to this message

From: ABX
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 06:37:31
Message: <2rf0uvgs063ijqivd14srq88lu2jireo8h@4ax.com>
On Wed, 17 Dec 2003 12:30:11 +0100, Nicolas Calimet <pov### [at] freefr> wrote:
> Can't you check whether a file exists or not

... with file_exists() in SDL of 3.5?

ABX


Post a reply to this message

From: Warp
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 10:04:10
Message: <3fe0706a@news.povray.org>
Peter Popov <pet### [at] vipbg> wrote:
> Probably the only thing this is potentially useful for is for file
> operations (#include, #fopen, image_map, density_file, bump_map,
> texture_map etc.)

  How about just using file_exists()? (See section 6.1.3.6 of the POV-Ray
documentation.)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: ingo
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 11:35:01
Message: <Xns9454B2DECCF7Bseed7@netplex.aussie.org>
in news:vu90uv8qe10h1kfnf0ho8ipt3voq1i1p19@4ax.com Peter Popov wrote:

> What do you guys think?
> 

During writing mesh generation macros I often wished there woud be a try 
except thingy. There are cases where POV-Ray just continues parsing 
although the results are wrong, for example nomalising a zero length 
vector.

Ingo


Post a reply to this message

From: Christoph Hormann
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 11:52:06
Message: <85e6b1-a3b.ln1@triton.imagico.de>
ingo wrote:
> 
> During writing mesh generation macros I often wished there woud be a try 
> except thingy. There are cases where POV-Ray just continues parsing 
> although the results are wrong, for example nomalising a zero length 
> vector.

But this is not the kind of situation a try .. except block should be 
used for.  You can easily solve this with a simple #if.

A try .. except would be useful for something like what Peter mentioned 
if you do not only want to check for the existence of a file but also 
want to handle the case the file exists but is not a valid png image.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 25 Oct. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: ingo
Subject: Re: Error handling during parsing
Date: 17 Dec 2003 14:11:04
Message: <Xns9454CD541C618seed7@netplex.aussie.org>
in news:85e### [at] tritonimagicode Christoph Hormann wrote:

> But this is not the kind of situation a try .. except block should be 
> used for.  You can easily solve this with a simple #if.
> 

Yes,

Ingo


Post a reply to this message

From: Peter Popov
Subject: Re: Error handling during parsing
Date: 18 Dec 2003 06:59:29
Message: <qr43uvcbcktf1doelq09pr58ievj8vfm5e@4ax.com>
On 17 Dec 2003 10:04:10 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  How about just using file_exists()? (See section 6.1.3.6 of the POV-Ray
>documentation.)

You can check whether the file is there but not if does not generate a
parsing error. It can be an invalid image file, invalid density file,
or simply an include file generated from an external utility that for
some reason gives an error. You and ABX are right though, in that
file_exists() should be enough in most cases. Just not all.

File i/o aside, there are situations where some primitive exception
handling comes to the rescue. Even for debugging if not for release.
In any case such a feature could be useful for parse-intensive
applications such as particle systems, surface subdivision, your own
and Chris' mesh macros etc.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.