[mapserver-users] Query error messages
Silke Reimer
silke at intevation.de
Tue Sep 10 00:42:07 PDT 2002
On Mon, Sep 09, 2002 at 02:59:52PM +0100, Matthew Hatcher wrote:
> Thanks.
>
> Can't believe I missed something that obvious! But I'm now going to make it
> a little harder for you all! Assuming that an error occurs and the page is
> diverted to the url specified, is there any way to find out what the error
> was? I presume (haven't checked the code) that MapServer does a simple
> redirect to the page specified, rather than using it as a template, so it
> wouldn't be possible to use a template variable or would it?
If you interested to use a template you can apply the patch which
you find at the end of the mail. Afterwards you can use the keyword
ERROR_TEMPLATE in the Web object to specify a template which should
be used when the query was empty.
Please note that the patch was written for mapserver 3.5 and has
been adapted to the mapserver 3.6. So there will appear some warnings
when you apply the patch by the 'patch' command. You can ignore
them.
By the way: It could be interesting to incorporate the patch in the
current mapserver code.
Silke
>
> Matt.
>
> -----Original Message-----
> From: Marc Jacquin [mailto:jacquin at geosys-inc.com]
> Sent: 09 September 2002 13:05
> To: Matthew Hatcher; mapserver-users at lists.gis.umn.edu
> Subject: RE: [mapserver-users] Query error messages
>
>
> Matt,
>
> Check the ERROR [url] keyword in the Web object.
>
> Marc
>
--
Silke Reimer
Intevation GmbH http://intevation.de/
FreeGIS http://freegis.org/
----------- here comes the patch --------------------------
diff -uNr mapserver/map.h mapserver-3.5-dev/map.h
--- mapserver/map.h Fri Oct 5 05:44:57 2001
+++ mapserver-3.5-dev/map.h Wed Oct 10 11:20:06 2001
@@ -326,6 +326,8 @@
#endif
char *header, *footer;
char *empty, *error; /* error handling */
+ char *empty_template; /* show error message with a template */
+
rectObj extent; /* clipping extent */
double minscale, maxscale;
char *mintemplate, *maxtemplate;
diff -uNr mapserver/mapfile.c mapserver-3.5-dev/mapfile.c
--- mapserver/mapfile.c Wed Oct 3 05:33:13 2001
+++ mapserver-3.5-dev/mapfile.c Wed Oct 10 11:33:30 2001
@@ -2791,7 +2791,7 @@
web->extent.minx = web->extent.miny = web->extent.maxx = web->extent.maxy = -1.0;
web->template = NULL;
web->header = web->footer = NULL;
- web->error = web->empty = NULL;
+ web->error = web->empty = web->empty_template = NULL;
web->mintemplate = web->maxtemplate = NULL;
web->minscale = web->maxscale = -1;
web->log = NULL;
@@ -2807,6 +2807,7 @@
msFree(web->footer);
msFree(web->error);
msFree(web->empty);
+ msFree(web->empty_template);
msFree(web->maxtemplate);
msFree(web->mintemplate);
msFree(web->log);
@@ -2819,6 +2819,8 @@
{
fprintf(stream, " WEB\n");
if(web->empty) fprintf(stream, " EMPTY \"%s\"\n", web->empty);
+ if(web->empty_template) fprintf(stream, " EMPTY_TEMPLATE \"%s\"\n",
+ web->empty);
if(web->error) fprintf(stream, " ERROR \"%s\"\n", web->error);
if(web->footer) fprintf(stream, " FOOTER \"%s\"\n", web->footer);
if(web->header) fprintf(stream, " HEADER \"%s\"\n", web->header);
@@ -2841,6 +2841,9 @@
case(EMPTY):
if((web->empty = getString()) == NULL) return(-1);
break;
+ case(EMPTY_TEMPLATE):
+ if((web->empty_template = getString()) == NULL) return(-1);
+ break;
case(EOF):
msSetError(MS_EOFERR, NULL, "loadWeb()");
return(-1);
@@ -2904,6 +2904,10 @@
case(EMPTY):
msFree(web->empty);
web->empty = strdup(value);
+ break;
+ case(EMPTY_TEMPLATE):
+ if(web->empty_template) msFree(web->empty);
+ web->empty_template = strdup(value);
break;
case(ERROR):
msFree(web->error);
diff -uNr mapserver/mapfile.h mapserver-3.5-dev/mapfile.h
--- mapserver/mapfile.h Fri Sep 21 05:50:42 2001
+++ mapserver-3.5-dev/mapfile.h Wed Oct 10 11:48:44 2001
@@ -158,4 +158,6 @@
#define DUMP 1125
+#define EMPTY_TEMPLATE 1130
+
#endif /* MAPFILE_H */
diff -uNr mapserver/maplexer.l mapserver-3.5-dev/maplexer.l
--- mapserver/maplexer.l Fri Sep 21 05:50:42 2001
+++ mapserver-3.5-dev/maplexer.l Wed Oct 10 11:20:06 2001
@@ -110,6 +110,7 @@
<INITIAL,OBJECT_STRING>data { return(DATA); }
<INITIAL,OBJECT_STRING>dump { return(DUMP); }
<INITIAL,OBJECT_STRING>empty { return(EMPTY); }
+<INITIAL,OBJECT_STRING>empty_template { return(EMPTY_TEMPLATE); }
<INITIAL>end { return(END); }
<INITIAL,OBJECT_STRING>error { return(ERROR); }
<INITIAL,OBJECT_STRING>expression { return(EXPRESSION); }
diff -uNr mapserver/mapserv.c mapserver-3.5-dev/mapserv.c
--- mapserver/mapserv.c Wed Oct 10 11:49:44 2001
+++ mapserver-3.5-dev/mapserv.c Wed Oct 10 11:38:48 2001
@@ -83,8 +83,17 @@
exit(0);
}
- if((ms_error->code == MS_NOTFOUND) && (msObj->Map->web.empty)) {
- msRedirect(msObj->Map->web.empty);
+ if((ms_error->code == MS_NOTFOUND)
+ && (msObj->Map->web.empty || msObj->Map->web.empty_template)) {
+ if (msObj->Map->web.empty_template) {
+ /* set to mode to something other than QUERY so that writeError
+ * is not called recursively. */
+ msObj->Mode = BROWSE;
+ printf("Content-type: text/html%c%c", 10, 10);
+ msReturnPage(msObj, msObj->Map->web.empty_template, BROWSE, NULL);
+ } else {
+ msRedirect(msObj->Map->web.empty);
+ }
} else {
if(msObj->Map->web.error) {
msRedirect(msObj->Map->web.error);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020910/a9e796f9/attachment.sig>
More information about the MapServer-users
mailing list