2014-03-16

Reverted edits by 176.193.164.242 (talk) to last revision by Jeroen De Dauw

← Older revision

Revision as of 11:14, 16 March 2014

Line 16:

Line 16:

 

 

 

== Do not use <tt>exit()</tt> ==

 

== Do not use <tt>exit()</tt> ==



Exiting from a script abruptly should almost never be done. Doing so will make your code untestable by PHPUnit. If your code encounters an unexpected error, the proper thing to do is throw an except<math>бждд

+

Exiting from a script abruptly should almost never be done. Doing so will make your code untestable by PHPUnit. If your code encounters an unexpected error, the proper thing to do is throw an exception like:



</math>

+

:<source lang="php">throw new MWException( "Oh noes!" );</source>



 

 

This will allow PHPUnit and MediaWiki to exit properly and provide informative information such as stack traces to developers.

 

This will allow PHPUnit and MediaWiki to exit properly and provide informative information such as stack traces to developers.

 

 

Show more