Index: core/units/helpers/deployment_helper.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/helpers/deployment_helper.php (revision 15892) +++ core/units/helpers/deployment_helper.php (revision ) @@ -252,13 +252,20 @@ return false; } + try { - if ( $this->dryRun ) { - $this->exportLanguagePack(); - } - else { - $this->importLanguagePack(); - } + if ( $this->dryRun ) { + $this->exportLanguagePack(); + } + else { + $this->importLanguagePack(); + } + } + catch ( Exception $e ) { + echo $this->colorText('Failed with Module "' . $module_name . '".', 'red', true) . PHP_EOL . PHP_EOL; + return false; + } + echo $this->colorText('Done with Module "' . $module_name . '".', 'green', true) . PHP_EOL . PHP_EOL; return true; @@ -490,33 +497,33 @@ $sqls = explode(";\n", $no_comment_sqls . "\n"); // ensures that last sql won't have ";" in it $sqls = array_map('trim', $sqls); + try { - foreach ($sqls as $sql) { - if ( substr($sql, 0, 1) == '#' ) { - // output comment as is - $this->toLog($sql); - echo $this->colorText($sql, 'purple') . PHP_EOL; - continue; - } - elseif ( $sql ) { - $this->toLog($sql . ' ... ', false); - $escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql); - echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... '; + foreach ($sqls as $sql) { + if ( substr($sql, 0, 1) == '#' ) { + // output comment as is + $this->toLog($sql); + echo $this->colorText($sql, 'purple') . PHP_EOL; + continue; + } + elseif ( $sql ) { + $this->toLog($sql . ' ... ', false); + $escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql); + echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... '; - $this->Conn->Query($sql); + $this->Conn->Query($sql); - if ( $this->Conn->hasError() ) { - // consider revisions with errors applied - $this->appliedRevisions[] = $revision; - - return false; - } - else { $this->toLog('OK (' . $this->Conn->getAffectedRows() . ')'); $this->displayStatus('OK (' . $this->Conn->getAffectedRows() . ')'); } } } + catch (Exception $e) { + // consider revisions with errors applied + $this->appliedRevisions[] = $revision; + return false; + } + $this->appliedRevisions[] = $revision; } @@ -526,13 +533,14 @@ } /** - * Error handler for sql errors + * Error handler for sql errors. * - * @param int $code - * @param string $msg - * @param string $sql - * @return bool - * @access public + * @param integer $code Error code. + * @param string $msg Error message. + * @param string $sql SQL query. + * + * @return void + * @throws Exception When SQL error happens. */ public function handleSqlError($code, $msg, $sql) { @@ -541,7 +549,7 @@ $this->displayStatus('FAILED' . PHP_EOL . 'SQL Error #' . $code . ': ' . $msg); $this->out('Please execute rest of SQLs in this Revision by hand and run deployment script again.', true); - return true; + throw new Exception($msg, $code); } /** @@ -678,4 +686,4 @@ echo $text . ($new_line ? PHP_EOL : ''); } -} \ No newline at end of file +}