[Mapbender-dev] JS exceptions

Marc Jansen jansen.marc at gmx.de
Thu Jan 11 06:59:34 EST 2007

Hey Christoph,

it's me again...

Christoph Baudson schrieb:
> Hi there,
> when thinking about a return value for Mapbender JS exceptions, I 
> encountered the following problem. Maybe I'm missing a central, please 
> enlighten me:
> when I call the JS class Mb_exception, I'll fire the Ajax post 
> function.  The callback function is invoked, but it can't return the 
> value to the original caller, because that's in a different function.
> see http://www.mapbender.org/index.php/Talk:For_developers#return_value
> Another solution might be to set a member variable of the class 
> (boolean $exceptionThrown); but again, because of the asynchronous 
> nature of Ajax, this would not work because I would want a return 
> value in the JS code rightaway.

I just thought a second and think there is some points to concider:

Having a return value would be nice, but is *not* essential.
What about a global variable

var hasLoggedExceptions = false;

The callback function could then set this to true, and anyone who wants 
to react on this, simply has to test this var:

function willOnlyWorkIfNoPreviousErrorsWereLogged () {
  if (hasLoggedExceptions ) {
    return false;

We cannot satisfy that this is always logically (as for programming 
purposes) true, because of the already mentioned asynchronous aspect. So 
the problem remains somewhat unsolved.
Some of the libraries I know provide a way of having *synchronous 
server-client-scripting*, but I'm not really sure, if we want to add 
this (especially for something 'dull', like logging). The aproach is in 
most cases, that some sort of timeout is set, and then return values are 
checked again and again. One might imagine, that this could result in a 
blocked UI, which is certainly not desireable.

That said, how are we going to do it now?

-- Marc

More information about the Mapbender_dev mailing list