From ac00050e37846348f7bebe7129ba35957be9d04d Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 21 Nov 2013 15:22:47 -0800 Subject: [PATCH] Handle CDB errors more gracefully in cdb.php maintenance script Change-Id: I9be42c909c85cd454fdd10921c8d50d6273252f8 --- maintenance/cdb.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/maintenance/cdb.php b/maintenance/cdb.php index d42f9f7a88..bda64f3eab 100644 --- a/maintenance/cdb.php +++ b/maintenance/cdb.php @@ -75,7 +75,10 @@ do { } $file = $args[0]; print "Loading cdb file $file..."; - $fileHandle = CdbReader::open( $file ); + try { + $fileHandle = CdbReader::open( $file ); + } catch( CdbException $e ) {} + if ( !$fileHandle ) { print "not a cdb file or unable to read it\n"; } else { @@ -91,7 +94,11 @@ do { print "Need to specify a key, Luke\n"; break; } - $res = $fileHandle->get( $args[0] ); + try { + $res = $fileHandle->get( $args[0] ); + } catch ( CdbException $e ) { + print "Unable to read key from file\n"; + } if ( $res === false ) { print "No such key/value pair\n"; } elseif ( is_string( $res ) ) { -- 2.20.1