What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [split] show error toast instead of in debug window

[split] show error toast instead of in debug window
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [Release] Fake media 1.60
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.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-10-2010 12:47 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
RE: [Release] Fake media 1.60 - by whiz on 06-09-2010 at 04:29 PM
RE: [split] show error toast instead of in debug window - by SmokingCookie on 06-11-2010 at 04:35 PM
RE: [split] show error toast instead of in debug window - by whiz on 06-11-2010 at 07:19 PM
RE: [split] show error toast instead of in debug window - by Matti on 06-12-2010 at 07:25 AM
RE: [split] show error toast instead of in debug window - by whiz on 06-12-2010 at 11:30 AM
RE: [split] show error toast instead of in debug window - by SmokingCookie on 06-12-2010 at 05:14 PM
RE: [split] show error toast instead of in debug window - by whiz on 06-13-2010 at 10:14 AM
RE: [split] show error toast instead of in debug window - by SmokingCookie on 06-13-2010 at 10:28 AM
RE: [split] show error toast instead of in debug window - by whiz on 06-13-2010 at 01:12 PM
RE: [Release] Fake media 1.60 - by SmokingCookie on 06-09-2010 at 04:41 PM
RE: [Release] Fake media 1.60 - by whiz on 06-09-2010 at 05:20 PM
RE: [Release] Fake media 1.60 - by SmokingCookie on 06-09-2010 at 05:27 PM
RE: [Release] Fake media 1.60 - by CookieRevised on 06-10-2010 at 11:26 AM
RE: [Release] Fake media 1.60 - by whiz on 06-10-2010 at 11:30 AM
RE: [Release] Fake media 1.60 - by Matti on 06-10-2010 at 12:47 PM
RE: [Release] Fake media 1.60 - by whiz on 06-10-2010 at 06:36 PM
RE: [Release] Fake media 1.60 - by SmokingCookie on 06-10-2010 at 06:41 PM
RE: [Release] Fake media 1.60 - by whiz on 06-10-2010 at 06:58 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On