Just out of interest, how do you make Plus! show a toast with an error code instead of an error in the Debug window? I had a quick look at your code but couldn't see it...
quote:Originally posted by whiz
Just out of interest, how do you make Plus! show a toast with an error code instead of an error in the Debug window? I had a quick look at your code but couldn't see it...
Afaik there isn't any magic or hidden setting to enable this.
You show the toast and error yourself.
Do this by using the try {} catch( e) {} methods. And in the catch show a toast with the error number (e.number).
So this wont work for all errors though, only the stuff you 'catch'.
This post was edited on 06-10-2010 at 11:26 AM by CookieRevised.
The sample code you defined there won't trigger an exception since you're not calling the functions inside your try block, you are just defining them. Due to the nature of JScript's treatment of global objects, it won't check for the existence of foo on declaration, since foo could still be assigned later. Therefore, there's no real use in wrapping function declarations in try-catch blocks.
Perhaps the best way to implement custom exception handling for all your functions, is to wrap the code inside all your event handlers such as OnEvent_Initialize or OnChatWndEvent_Created.
js code:// Main event, wrapped in try-catch block
function OnEvent_Initialize() {
try {
DoThis();
DoThat();
} catch(error) {
MsgPlus.DisplayToast("Error!", error.description);
}
}
// Script functions calling each other
function DoThis() {
HelpMeWithThis();
CallingUnknownFunction(); // try-catch in main event catches this
}
function HelpMeWithThis() { ... }
function DoThat() { ... }
As you can see, despite being wrapped in other functions, the exception will still reach the try-catch block in the event handler. These are the starting points of your call stacks, so any exception occurring inside a function called from the event will bubble up in the call stack until it hits the try-catch block in your event handler code.
quote:Originally posted by Matti
Perhaps the best way to implement custom exception handling for all your functions, is to wrap the code inside all your event handlers such as OnEvent_Initialize or OnChatWndEvent_Created.
<code>
As you can see, despite being wrapped in other functions, the exception will still reach the try-catch block in the event handler. These are the starting points of your call stacks, so any exception occurring inside a function called from the event will bubble up in the call stack until it hits the try-catch block in your event handler code.
code:From the Plus! Script Debug...
Error: Object doesn't support this property or method (code: -2146827850)
File: FnInitialization.js. Line: 72.
Function OnEvent_Initialize returned an error. Code: -2147352318
quote:Originally posted by SmokingCookie
Pleaaaaase don't go offtopic, or my thread will be closed