Just a question.
Is the JSEvent also given as parameter to the errorhandler?
In case the errorhandler is triggered, I would like to know what event has caused this error
Just a question.
Is the JSEvent also given as parameter to the errorhandler?
In case the errorhandler is triggered, I would like to know what event has caused this error
Martin,
When you assign a method to an event in Servoy 5, you can choose to create a new method.
These methods are created according to a template that matches the signature expected for that event.
Rob
Hi Rob,
I’m nore sure if you understood my question, or that I understand your reply
What I mean is that in the solution properties, you can say onError and link a global method to it (the errorhandler)
Does this errorhandler when it is called (and this is always unexpected, never know from where it is called) also has the JSEvent as parameter, so that I can show formname, elementname, etc in the errorhandler (like I now use those application.trigger methods)
Martin
Martin,
I meant as a general way to check the signature you can create a new method.
When you do this for the solution onerr method, you will see that there is just 1 arg, the exception that occurred.
Rob
OK,
Can it be useful to add a request to add the JSEvent also as passed argument (arg 2), or is that technically not possible?
Martin,
Since the exception can be thrown from anywhere, the formname, elementname, etc in an event would not be very reliable.
If you use the application.trigger methods methods you just get the last ones used, it does not have to be the cause of the error.
Rob
Hi Rob,
rgansevles:
If you use the application.trigger methods methods you just get the last ones used, it does not have to be the cause of the error.
I agree that this is not always the cause of the error, but showing the last form/elementname helps me to find the reason for an exception
The application.trigger methods were available on any moment in script. Even when these methods do not return a value, I could still call them and they gave me the last value if there was one.
Since the JSEvent is passed as a parameter I would have to save this JSEvent in a global on every method that is behind an event, and in the exception check the contents of that global.
That means a lot of scripting needs to be changed.
Maybe a new method could be a solution:
application.getLastEvent() which returns the last JSEvent object.
In that case if works similar like before with those application.trigger methods
Martin
martinh:
Maybe a new method could be a solution:
application.getLastEvent() which returns the last JSEvent object.
I agree, a new method would be nice to handle the JSEvent object.
What I would like is something like this:
var vArgs = arguments[0]
if(vArgs && vArgs.isJSEvent() == true){
//do something
}
I tried typeof vArgs, but that doesn’t tell me if the passed object is a ‘real’ JSEvent…
This will work:
if (arguments[0] instanceof JSEvent) {...}
Paul
pbakker:
This will work:if (arguments[0] instanceof JSEvent) {...}
Nice! Thanks Paul.