summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2001-02-28 08:15:30 +0000
committerFrank Schönheit <fs@openoffice.org>2001-02-28 08:15:30 +0000
commitaf33fe8c9bce794eb916a67c3950b3a8ded74a95 (patch)
tree025064ff6775c1096607045236b0a44e677146ea /connectivity
parentcbca86f07d9ce98ef12dd5760714d09e622561d7 (diff)
added invalidity message - don't throw exceptions from within the table ctor
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx45
-rw-r--r--connectivity/source/drivers/dbase/DTables.cxx9
-rw-r--r--connectivity/source/inc/dbase/DTable.hxx10
3 files changed, 41 insertions, 23 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 0cb76ff7ab4f..43475795511a 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DTable.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: oj $ $Date: 2001-02-22 13:53:00 $
+ * last change: $Author: fs $ $Date: 2001-02-28 09:15:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -168,8 +168,9 @@ void ODbaseTable::readHeader()
m_bValid = sal_False;
::rtl::OUString sMessage = ::rtl::OUString::createFromAscii("[StarOffice Base dbase] The file '");
sMessage += getEntry();
- sMessage += ::rtl::OUString::createFromAscii("' is no valid (or recognized) dBase file.");
- throwGenericSQLException(sMessage, static_cast<XNamed*>(this));
+ sMessage += ::rtl::OUString::createFromAscii(" is an invalid (or unrecognized) dBase file.");
+ m_sInvalidityMessage = sMessage;
+ m_bValid = sal_False;
}
else
{
@@ -194,8 +195,9 @@ void ODbaseTable::readHeader()
// no dbase file
::rtl::OUString sMessage = ::rtl::OUString::createFromAscii("[StarOffice Base dbase] The file ");
sMessage += getEntry();
- sMessage += ::rtl::OUString::createFromAscii(" is no valid (or recognized) dBase file.");
- throwGenericSQLException(sMessage, static_cast<XNamed*>(this));
+ sMessage += ::rtl::OUString::createFromAscii(" is an invalid (or unrecognized) dBase file.");
+ m_sInvalidityMessage = sMessage;
+ m_bValid = sal_False;
}
}
}
@@ -1103,13 +1105,23 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo)
if (aName.getLength() > nMaxFieldLength)
{
+<<<<<<< DTable.cxx
+ String sError;
+ sError.AppendAscii("Invalid length (>");
+ sError += String::CreateFromInt32(nMaxFieldLength);
+ sError.AppendAscii(") for field name ");
+ sError += aName.getStr();
+ throwGenericSQLException(sError, static_cast<XNamed*>(this));
+ break;
+=======
::rtl::OUString sMsg = ::rtl::OUString::createFromAscii("Invalid column name length for column: ");
sMsg += aName;
sMsg += ::rtl::OUString::createFromAscii("!");
throw SQLException(sMsg,*this,::rtl::OUString::createFromAscii("HY0000"),1000,Any());
+>>>>>>> 1.27
}
- ByteString aCol(aName.getStr(),gsl_getSystemTextEncoding());
+ ByteString aCol(aName.getStr(), getConnection()->getTextEncoding());
(*m_pFileStream) << aCol.GetBuffer();
m_pFileStream->Write(aBuffer, 11 - aCol.Len());
@@ -1811,7 +1823,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer
String aString;
SolarMath::DoubleToString(aString,n,'F',nScale,'.');
- ByteString aDefaultValue(aString,gsl_getSystemTextEncoding());
+ ByteString aDefaultValue(aString, getConnection()->getTextEncoding());
BOOL bValidLength = sal_False;
if (aDefaultValue.Len() <= nLen)
{
@@ -1822,14 +1834,15 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer
}
if (!bValidLength)
{
-// String strError(SdbResId(STR_DBF_INVALID_FIELD_VALUE));
-// strError.SearchAndReplace(String::CreateFromAscii("$name$"), pColumn->GetName());
-//
-// String strDetailedInformation(SdbResId(STR_DBF_INVALID_FIELD_VALUE_DECIMAL));
-// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("$name$"), pColumn->GetName());
-// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("#length#"), nPrecision);
-// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("#scale#"), nScale);
-// aStatus.Set(SDB_STAT_ERROR, String::CreateFromAscii("S1000"), aStatus.CreateErrorMessage(strError), 0, strDetailedInformation);
+ String sError;
+ sError.AppendAscii("The ");
+ sError += aColName.getStr();
+ sError.AppendAscii(" column has been defined as a \"Decimal\" type, the max. length is ");
+ sError += String::CreateFromInt32(nPrecision);
+ sError.AppendAscii(" characters (with ");
+ sError += String::CreateFromInt32(nScale);
+ sError.AppendAscii(" decimal places).\n\nThe specified value is longer than the number of digits allowed.");
+ throwGenericSQLException(sError, static_cast<XNamed*>(this));
}
} break;
case DataType::BIT:
diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx
index b45c9a18ba6a..248ec810ebb9 100644
--- a/connectivity/source/drivers/dbase/DTables.cxx
+++ b/connectivity/source/drivers/dbase/DTables.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DTables.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: oj $ $Date: 2001-02-22 13:53:00 $
+ * last change: $Author: fs $ $Date: 2001-02-28 09:15:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,7 +122,10 @@ Reference< XNamed > ODbaseTables::createObject(const ::rtl::OUString& _rName)
if(!pRet->isValid())
{
::comphelper::disposeComponent(xRet);
- throw SQLException(::rtl::OUString::createFromAscii("Invalid DBase file found!"),m_rParent,_rName,1000,Any());
+ String sMessage = pRet->getInvalidityMessage();
+ if (!sMessage.Len())
+ sMessage = String::CreateFromAscii("Invalid DBase file found!");
+ throw SQLException(sMessage, m_rParent, _rName, 1000, Any());
}
return xRet;
diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx
index 0accee695e25..4a182247cfc5 100644
--- a/connectivity/source/inc/dbase/DTable.hxx
+++ b/connectivity/source/inc/dbase/DTable.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DTable.hxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: oj $ $Date: 2001-02-22 13:52:12 $
+ * last change: $Author: fs $ $Date: 2001-02-28 09:15:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -138,6 +138,7 @@ namespace connectivity
SvStream* m_pMemoStream;
sal_Bool m_bWriteableMemo;
sal_Bool m_bValid; // set to false when this isn't a correct dbase table
+ String m_sInvalidityMessage;
void readHeader();
void fillColumns();
@@ -187,8 +188,9 @@ namespace connectivity
BOOL DropImpl();
BOOL CreateImpl();
- String getEntry();
- sal_Bool isValid() { return m_bValid; }
+ String getEntry();
+ sal_Bool isValid() { return m_bValid; }
+ String getInvalidityMessage() const { return m_sInvalidityMessage; }
virtual BOOL InsertRow(file::OValueVector& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
virtual BOOL DeleteRow(const OSQLColumns& _rCols);