[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7885] setup: improved errorhandling
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7885] setup: improved errorhandling |
Date: |
Sun, 16 Oct 2011 13:02:12 +0000 |
Revision: 7885
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7885
Author: sigurdne
Date: 2011-10-16 13:02:11 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
setup: improved errorhandling
Modified Paths:
--------------
trunk/phpgwapi/inc/class.schema_proc.inc.php
Modified: trunk/phpgwapi/inc/class.schema_proc.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.schema_proc.inc.php 2011-10-16 11:23:43 UTC
(rev 7884)
+++ trunk/phpgwapi/inc/class.schema_proc.inc.php 2011-10-16 13:02:11 UTC
(rev 7885)
@@ -72,44 +72,49 @@
$sSequenceSQL = '';
$sTriggerSQL = '';
$this->m_oTranslator->indexes_sql = array();
- if($this->_GetTableSQL($sTableName, $aTableDef,
$sTableSQL, $sSequenceSQL, $sTriggerSQL))
+
+ try
{
- $sTableSQL = "CREATE TABLE $sTableName
(\n$sTableSQL\n)"
- .
$this->m_oTranslator->m_sStatementTerminator;
- if($sSequenceSQL != '')
- {
- $sAllTableSQL .= $sSequenceSQL
. "\n";
- }
+ $this->_GetTableSQL($sTableName,
$aTableDef, $sTableSQL, $sSequenceSQL, $sTriggerSQL);
+ }
- if($sTriggerSQL != '')
- {
- $sAllTableSQL .= $sTriggerSQL .
"\n";
- }
-
- $sAllTableSQL .= $sTableSQL . "\n\n";
-
- // postgres and mssql
-
if(isset($this->m_oTranslator->indexes_sql) &&
is_array($this->m_oTranslator->indexes_sql) &&
count($this->m_oTranslator->indexes_sql)>0)
- {
-
foreach($this->m_oTranslator->indexes_sql as $key => $sIndexSQL)
- {
- $ix_name =
$key.'_'.$sTableName.'_idx';
- $IndexSQL =
str_replace(array('__index_name__','__table_name__'),
array($ix_name,$sTableName), $sIndexSQL);
- $sAllTableSQL .=
$IndexSQL . "\n\n";
- }
- }
- }
- else
+ catch(Exception $e)
{
if($bOutputHTML)
{
print('<br>SQL:<pre>' .
$sAllTableSQL . '</pre><br>');
- print('<br>Failed generating
script for <b>' . $sTableName . '</b><br>');
- echo '<pre style="text-align:
left;">'.$sTableName.' = '; print_r($aTableDef); echo "</pre>\n";
}
+ print('<br>Error: Failed generating
script for <b>' . $sTableName . '</b><br>');
+ echo '<pre style="text-align:
left;">'.$sTableName.' = '; print_r($aTableDef); echo "</pre>\n";
+ echo $e->getMessage();
return false;
}
+
+ $sTableSQL = "CREATE TABLE $sTableName
(\n$sTableSQL\n)"
+ .
$this->m_oTranslator->m_sStatementTerminator;
+ if($sSequenceSQL != '')
+ {
+ $sAllTableSQL .= $sSequenceSQL . "\n";
+ }
+
+ if($sTriggerSQL != '')
+ {
+ $sAllTableSQL .= $sTriggerSQL . "\n";
+ }
+
+ $sAllTableSQL .= $sTableSQL . "\n\n";
+
+ // postgres and mssql
+ if(isset($this->m_oTranslator->indexes_sql) &&
is_array($this->m_oTranslator->indexes_sql) &&
count($this->m_oTranslator->indexes_sql)>0)
+ {
+
foreach($this->m_oTranslator->indexes_sql as $key => $sIndexSQL)
+ {
+ $ix_name =
$key.'_'.$sTableName.'_idx';
+ $IndexSQL =
str_replace(array('__index_name__','__table_name__'),
array($ix_name,$sTableName), $sIndexSQL);
+ $sAllTableSQL .= $IndexSQL .
"\n\n";
+ }
+ }
}
if($bOutputHTML)
@@ -321,29 +326,34 @@
while(list($sFieldName, $aFieldAttr) =
each($aTableDef['fd']))
{
$sFieldSQL = '';
- if($this->_GetFieldSQL($aFieldAttr, $sFieldSQL))
+
+ try
{
- if($sTableSQL != '')
- {
- $sTableSQL .= ",\n";
- }
+ $this->_GetFieldSQL($aFieldAttr,
$sFieldSQL);
+ }
+ catch(Exception $e)
+ {
+ $_message = "Error: GetFieldSQL failed
for <b>{$sTableName}::{$sFieldName}</b>. ";
+ $_message .= $e->getMessage();
+ throw new Exception($_message);
+ return False;
+ }
+
+ if($sTableSQL != '')
+ {
+ $sTableSQL .= ",\n";
+ }
- $sTableSQL .= "$sFieldName $sFieldSQL";
+ $sTableSQL .= "$sFieldName $sFieldSQL";
- if($aFieldAttr['type'] == 'auto')
+ if($aFieldAttr['type'] == 'auto')
+ {
+ $sbufTriggerFD[] = $sFieldName;
+
if($this->m_oTranslator->GetSequenceSQL($sTableName, $sSequenceSQL))
{
- $sbufTriggerFD[] = $sFieldName;
-
if($this->m_oTranslator->GetSequenceSQL($sTableName, $sSequenceSQL))
- {
- $sTableSQL .= sprintf("
DEFAULT nextval('seq_%s')", $sTableName);
- }
+ $sTableSQL .= sprintf(" DEFAULT
nextval('seq_%s')", $sTableName);
}
}
- else
- {
- if($DEBUG) { echo 'GetFieldSQL failed
for ' . $sFieldName; }
- return False;
- }
}
$sUCSQL = '';
@@ -521,9 +531,11 @@
if($DEBUG) { echo '<br>_GetFieldSQL(): Outgoing
SQL: ' . $sFieldSQL; }
return true;
}
+ else
+ {
+ throw new Exception( 'Failed to translate
field: type[' . $sType . '] precision[' . $iPrecision . '] scale[' . $iScale .
']');
+ }
- if($DEBUG) { echo '<br>Failed to translate field:
type[' . $sType . '] precision[' . $iPrecision . '] scale[' . $iScale .
']<br>'; }
-
return False;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7885] setup: improved errorhandling,
Sigurd Nes <=