r105311 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105310‎ | r105311 | r105312 >
Date:16:31, 6 December 2011
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
nicely exit when we can not create a directory
Modified paths:
  • /trunk/tools/testswarm/scripts/testswarm-mw-fetcher.php (modified) (history)

Diff [purge]

Index: trunk/tools/testswarm/scripts/testswarm-mw-fetcher.php
@@ -298,10 +298,15 @@
299299 public function mkdir( $path ) {
300300 $this->debug( "Attempting to create directory '$path'...", __METHOD__ );
301301 if ( !file_exists( $path ) ) {
302 - if ( mkdir( $path, 0777, true ) ) {
303 - $this->debug( "Created directory '$path'", __METHOD__ );
304 - } else {
305 - throw new Exception( __METHOD__ . ": Failed to create directory '$path'" );
 302+ try {
 303+ if ( @mkdir( $path, 0777, true ) ) {
 304+ $this->debug( "Created directory '$path'", __METHOD__ );
 305+ } else {
 306+ throw new Exception( __METHOD__ . ": Failed to create directory '$path'" );
 307+ }
 308+ } catch( Exception $e ) {
 309+ print "Could not create directory '$path'. Exiting.\n";
 310+ exit(1);
306311 }
307312 } else {
308313 $this->debug( "Creating directory '$path' aborted. Directory already exist", __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r105314get ride of useless exception throwing...hashar16:44, 6 December 2011

Comments

#Comment by 😂 (talk | contribs)   16:33, 6 December 2011

Rather than throwing and immediately catching the exception, why not just bit the print and exit calls in the else block?

#Comment by 😂 (talk | contribs)   16:33, 6 December 2011

s/bit/put/

#Comment by Hashar (talk | contribs)   16:44, 6 December 2011

Fixed in follow up :-)

Status & tagging log