spacer
Yehuda Shiran May 5, 2001
Suppressing Error Messages
Tips: May 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
Suppressing error messages is a controversial issue in all programming languages. That's a classical programmer dilemma. Should a program screams when a bug is found, or should the bug go unnoticed? Since this is a "religious" issue, it is left for your own decision. What is not questionable is the need for error messages during early development stages of the program. In this phase, you probably need the error messages for debugging your new script.

FlashSound JavaScript API lets you choose whether to suppress error message or not, with the muteErrorMsg property of the FlashSound object. Notice the double negative here. In order to suppress error message, you need to set this property to false. Set it to true during the debugging phase. The default setting is true, i.e. error messages are suppressed by default.

As a reminder, in order to sonify your page, follow this recipe:

  • Make sure you have the Flash player. 96% of the surfing population already has it. Download.
  • Include flashsound.js in the HEAD section. Download.
  • Create a flashsound object in the HEAD section.
  • Embed your SWF file in the BODY section.
  • Create an anchor tag and set the onmouseover event handler to the TGotoAndPlay() method.

The following JavaScript code include an error, because the variable a is not defined:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

We can choose to get or suppress an error message for this JavaScript error. The following script will suppress the error:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = true;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

And the following script will reveal the error:

<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = false;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>

Click the following two links to see a demo for each of these two file:

Reveal Error Messages

Suppress Error Messages

Here is the source code for the file that reveals the error:

<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = false;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>
</BODY>
</HTML>

And here is the source code for the file that suppress the error:

<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
  FlashSound.muteErrorMsg = true;
  FlashSound.muteErrorMsg = a;  
</SCRIPT>
</BODY>
</HTML>

Here is a link you can use to download flashsound.js.

Download flashsound.js


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags