Closed tbonfort closed 12 years ago
Author: dmorissette Date: 2003/07/10 - 20:44
I'll do this in the PHP MapScript now.
That will leave the CGI and SWIG Mapscript ones to do.
Author: dmorissette Date: 2003/07/10 - 23:26
Ok, I've done it for PHP, I could do the CGI version now if you haven't
started yet Frank since it's just a simple while loop.
Note that at the same time I took the liberty of making the mapfile.c parsing
errors more clear. Also made them return the right line number by initializing
msyylineno=1 instead of msyylineno=0.
So now instead of getting this:
getString(): (grid):(274)
you get this:
getString(): Parsing error near (grid):(line 275)
Author: dmorissette Date: 2003/07/11 - 00:13
I've added a loop to msWriteError() to return the whole error stack from the
mapserv CGI but I was unable to produce any error with multiple messages with
the CGI. Dave can you please try with this error that you got with PostGIS and
confirm that it works fine?
What's left to do in this bug:
1- msWriteErrorImage() needs to be modified to output the whole stack as well
2- Do the SWIG-based versions of MapScript need any change for this?
Author: dblasby@refractions.net Date: 2003/07/11 - 00:41
I tried shp2img - it shows both errors (it only showed one before). Good fix!
Author: fwarmerdam Date: 2003/07/11 - 00:55
Daniel, you rock.
Author: sdlime Date: 2003/07/14 - 17:20
How are errors exposed via PHP
Author: sdlime Date: 2003/07/14 - 17:24
How are errors exposed exposed via PHP, via a method? I'd like to do something
similar for the MapScript side of things (stopping short of Sean's exception
handling for the moment). I'll take a look at Dan's implementation and fix the
CGI version to use it. Might need a seperate "web" version that uses a
different end-of-line delimiter (i.e. <br>).
Steve
Author: assefa Date: 2003/07/14 - 17:33
Here is the doc from the php README on errors :
errorObj
--------
Instances of errorObj are created internally by MapServer as errors
happen. Errors are managed as a chained list with the first item being
the most recent error. The head of the list can be fetched using
ms_GetErrorObj(), and the list can be cleared using ms_ResetErrorList()
Functions:
errorObj ms_GetErrorObj()
Returns a reference to the head of the list of errorObj.
void ms_ResetErrorList()
Clear the current error list.
Note that clearing the list invalidates any errorObj handles obtained
via the $error->next() method.
Members:
int code /* See error code constants above */
string routine
string message
Method:
errorObj next()
Returns the next errorObj in the list, or NULL if we reached the end
of the list.
Example:
This example draws a map and reports all errors generated during
the draw() call, errors can potentially come from multiple layers.
ms_ResetErrorList();
$img = $map->draw();
$error = ms_GetErrorObj();
while($error && $error->code != MS_NOERR)
{
printf("Error in %s: %s<br>\n", $error->routine, $error->message);
$error = $error->next();
}
Author: sdlime Date: 2003/07/15 - 07:43
I added support similar to the PHP MapScript code to SWIG MapScript tonite. I've
only tested with Perl but it seems to work fine. Usage would be something like:
------------------------------ snip ---------------------------------------
#!/usr/bin/perl
use mapscript;
$error = new mapscript::errorObj(); # this does a msGetErrorObj
# or $error = mapscript::msGetErrorObj();
$map = new mapscript::mapObj('demo.map') or die 'Unable to open map file.';
$img = $map->draw();
while($error && $error->{code} != $mapscript::MS_NOERR) {
print "Error in $error->{routine}: $error->{message}\n";
$error = $error->next();
}
mapscript::msResetErrorList();
------------------------------ snip ---------------------------------------
There are probably different ways to mix the msGetErrorObj and msResetErrorList
functions in the SWIG constructor/destructors. Of course those functions are
exposed so you could just call them instead of doing a new...
I also added a new function called msGetErrorString (the old msGetErrorString
was renamed more appropriately msGetErrorCodeString and changed where referenced
in the source). It may ultimately be more useful then the above way of getting
at errors, certainly easier for the casual user. In Perl usage is just:
$errstr = mapscript::msGetErrorString(',');
Where the parameter is a delimiter used to seperate error messages. At the
moment there are extra \n's being tagged onto the end of each message. Haven't
had time to figure out if it's Perl specific or not. Anyway that function does
the same thing as msWriteError but to a buffer, may work nicely with the
in-image errors since GD can handle multiline strings and will work for the CGI
as well. Getting there...
Author: sgillies@frii.com Date: 2003/07/16 - 02:38
Steve, the changes you made to mapscript.i and pymodule.i are fine as far
as I can tell. All my regression tests (mapscript/python/tests/testMapScript.py)
pass.
Author: sdlime Date: 2003/07/30 - 23:30
I'm closing this for now. We can deal with multi-line error images later (as a
more specific bug). This works fine via the CGI, Python/Perl MapScript and PHP
MapScript. msWriteError should probably use the msGetErrorString function (I'll
add a TODO to the source).
Reporter: sdlime Date: 2003/06/20 - 18:06