home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _cba15c40876594ad274af3c74edfaed3 < prev    next >
Text File  |  2000-03-23  |  6KB  |  134 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Tk::Error - Method invoked to process background errors</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> Tk::Error - Method invoked to process background errors</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#bugs">BUGS</A></LI>
  26.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  27.     <LI><A HREF="#keywords">KEYWORDS</A></LI>
  28. </UL>
  29. <!-- INDEX END -->
  30.  
  31. <HR>
  32. <P>
  33. <H1><A NAME="name">NAME</A></H1>
  34. <P>Tk::Error - Method invoked to process background errors</P>
  35. <P>
  36. <HR>
  37. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  38. <UL>
  39. <LI>Linux</LI>
  40. <LI>Solaris</LI>
  41. <LI>Windows</LI>
  42. </UL>
  43. <HR>
  44. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  45. <P>Customization:</P>
  46. <PRE>
  47.     require Tk::ErrorDialog;</PRE>
  48. <P>or</P>
  49. <PRE>
  50.     sub Tk::Error
  51.     {
  52.       my ($widget,$error,@locations) = @_;
  53.       ...</PRE>
  54. <PRE>
  55.     }</PRE>
  56. <P>
  57. <HR>
  58. <H1><A NAME="description">DESCRIPTION</A></H1>
  59. <P>The <STRONG>Tk::Error</STRONG> method is invoked by perl/Tk when a background
  60. error occurs. Two possible implementations are provided in the
  61. distribution and individual applications or users can (re)define a <STRONG>Tk::Error</STRONG>
  62. method (e.g. as a perl sub) if they wish to handle background
  63. errors in some other manner.</P>
  64. <P>A background error is one that occurs in a command that didn't
  65. originate with the application.  For example, if an error occurs
  66. while executing a <A HREF="../../../site/lib/Tk/callbacks.html">callback</A> specified with a
  67. <A HREF="../../../site/lib/Tk/bind.html">bind</A> or a <A HREF="../../../Tk/after.html">after</A>
  68. command, then it is a background error.  For a non-background error,
  69. the error can simply be returned up through nested subroutines
  70. until it reaches the top-level code in the application;
  71. then the application can report the error in whatever way it
  72. wishes.  When a background error occurs, the unwinding ends in
  73. the Tk library and there is no obvious way for Tk to report
  74. the error.</P>
  75. <P>When Tk detects a background error, it saves information about the
  76. error and invokes the <STRONG>Tk::Error</STRONG> method later when Tk is idle.</P>
  77. <P><STRONG>Tk::Error</STRONG> is invoked by perl/Tk as if by the perl code:</P>
  78. <P>    <EM>$mainwindow</EM>-><STRONG>Tk::Error</STRONG>(<EM>``error message''</EM>, <EM>location ...</EM>);</P>
  79. <P><EM>$mainwindow</EM> is the <STRONG>MainWindow</STRONG> associated with widget which
  80. detected the error, <EM>``error message''</EM> is a string describing the error
  81. that has been detected, <EM>location</EM> is a list of one or more ``locations''
  82. which describe the call sequence at the point the error was detected.</P>
  83. <P>The locations are a typically a mixture of perl location reports giving
  84. script name and line number, and simple strings describing locations in
  85. core Tk or perl/Tk C code.</P>
  86. <P>Tk will ignore any result returned by the <STRONG>Tk::Error</STRONG> method.
  87. If another error occurs within the <STRONG>Tk::Error</STRONG> method
  88. (for example if it calls <STRONG>die</STRONG>) then Tk reports this error
  89. itself by writing a message to stderr (this is to avoid infinite loops
  90. due to any bugs in <STRONG>Tk::Error</STRONG>).</P>
  91. <P>If several background errors accumulate before <STRONG>Tk::Error</STRONG>
  92. is invoked to process them, <STRONG>Tk::Error</STRONG> will be invoked once
  93. for each error, in the order they occurred.
  94. However, if <STRONG>Tk::Error</STRONG> calls <STRONG>Tk->break</STRONG>, then
  95. any remaining errors are skipped without calling <STRONG>Tk::Error</STRONG>.</P>
  96. <P>The <STRONG>Tk</STRONG> module includes a default <STRONG>Tk::Error</STRONG> subroutine
  97. that simply reports the error on stderr.</P>
  98. <P>An alternate definition is provided via :</P>
  99. <P>    <CODE>require Tk::ErrorDialog;</CODE></P>
  100. <P>that posts a dialog box containing the error message and offers
  101. the user a chance to see a stack trace showing where the
  102. error occurred.</P>
  103. <P>
  104. <HR>
  105. <H1><A NAME="bugs">BUGS</A></H1>
  106. <P>If <STRONG>after</STRONG> or <STRONG>fileevent</STRONG> are not invoked as methods of a widget
  107. then perl/Tk is unable to provide a <EM>$mainwindow</EM> argument.
  108. To support such code from earlier versions of perl/Tk
  109. perl/Tk therefore calls <STRONG>Tk::Error</STRONG> with string 'Tk' instead:
  110. <STRONG>Tk->Tk::Error\(...\)</STRONG>.
  111. In this case the <STRONG>Tk::Error</STRONG> in <STRONG>Tk::ErrorDialog</STRONG> and similar
  112. implementations cannot ``popup'' a window as they don't know which display
  113. to use.  A mechanism to supply <EM>the</EM> <STRONG>MainWindow</STRONG> in applications
  114. which only have one (a very common case) should be provided.</P>
  115. <P>
  116. <HR>
  117. <H1><A NAME="see also">SEE ALSO</A></H1>
  118. <P><A HREF="../../../site/lib/Tk/bind.html">Tk::bind</A>
  119. <A HREF="../../../Tk/after.html">Tk::after</A>
  120. <A HREF="../../../site/lib/Tk/fileevent.html">Tk::fileevent</A></P>
  121. <P>
  122. <HR>
  123. <H1><A NAME="keywords">KEYWORDS</A></H1>
  124. <P>background error, reporting</P>
  125. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  126. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  127. <STRONG><P CLASS=block> Tk::Error - Method invoked to process background errors</P></STRONG>
  128. </TD></TR>
  129. </TABLE>
  130.  
  131. </BODY>
  132.  
  133. </HTML>
  134.