diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-11 08:31:53 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-02-11 10:01:45 +0200 |
commit | 4bcc7ddf78ac987dc4b9c80aab203c2e719fb5aa (patch) | |
tree | 229fa78ec08129539c77ac7b01e06f3c1a269763 /idl | |
parent | e755ac76e04e696493b0557193b1a41f7eeb0657 (diff) |
simplify error handling code
Change-Id: I8f70d6bde7018d5b4455f95373f1b7d5dbc4d76e
Diffstat (limited to 'idl')
-rw-r--r-- | idl/inc/database.hxx | 1 | ||||
-rw-r--r-- | idl/source/objects/bastype.cxx | 5 | ||||
-rw-r--r-- | idl/source/objects/module.cxx | 5 | ||||
-rw-r--r-- | idl/source/objects/object.cxx | 21 | ||||
-rw-r--r-- | idl/source/objects/slot.cxx | 21 | ||||
-rw-r--r-- | idl/source/objects/types.cxx | 7 | ||||
-rw-r--r-- | idl/source/prj/database.cxx | 6 |
7 files changed, 21 insertions, 45 deletions
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index 680f569c882a..c435aaf85bda 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -111,6 +111,7 @@ public: sal_uLong nRow = 0, sal_uLong nColumn = 0 ); void WriteError( SvTokenStream & rInStm ); void SetError( const OString& rError, SvToken& rTok ); + void SetAndWriteError( SvTokenStream & rInStm, const OString& rError ); void Push( SvMetaObject * pObj ); sal_uInt32 GetUniqueId() { return ++nUniqueId; } bool FindId( const OString& rIdName, sal_uLong * pVal ); diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx index ae60b5551e05..d74aeb302c10 100644 --- a/idl/source/objects/bastype.cxx +++ b/idl/source/objects/bastype.cxx @@ -102,10 +102,7 @@ void SvIdentifier::ReadSvIdl( SvIdlDataBase & rBase, } else { - OStringBuffer aStr("no value for identifier <"); - aStr.append(getString()).append("> "); - rBase.SetError( aStr.makeStringAndClear(), rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "no value for identifier <" + getString() + "> " ); } } rInStm.Seek( nTokPos ); diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx index ad339b7c6055..e501939679de 100644 --- a/idl/source/objects/module.cxx +++ b/idl/source/objects/module.cxx @@ -43,10 +43,7 @@ void SvMetaModule::ReadAttributesSvIdl( SvIdlDataBase & rBase, sal_uInt32 nTokPos = rInStm.Tell(); if( !rBase.ReadIdFile( OStringToOUString(aSlotIdFile, RTL_TEXTENCODING_ASCII_US)) ) { - OStringBuffer aStr("cannot read file: "); - aStr.append(aSlotIdFile); - rBase.SetError( aStr.makeStringAndClear(), rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "cannot read file: " + aSlotIdFile ); rInStm.Seek( nTokPos ); } diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 1d02176a3642..38cfe6bc59fa 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -65,8 +65,7 @@ void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, else { // set error - rBase.SetError( "unknown imported interface", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "unknown imported interface" ); } } else @@ -120,8 +119,7 @@ bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) if( !bOk ) { // set error - rBase.SetError( "unknown super class", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "unknown super class" ); } } if( bOk ) @@ -158,11 +156,7 @@ bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, OSL_FAIL( pS->GetSlotId().getString().getStr() ); OSL_FAIL( rAttr.GetSlotId().getString().getStr() ); - OStringBuffer aStr("Attribute's "); - aStr.append(pS->GetName()); - aStr.append(" with different id's"); - rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken()); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError(rInStm, "Attribute's " + pS->GetName() + " with different id's"); return false; } } @@ -177,13 +171,8 @@ bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, OSL_FAIL( pS->GetSlotId().getString().getStr() ); OSL_FAIL( rAttr.GetSlotId().getString().getStr() ); - OStringBuffer aStr("Attribute "); - aStr.append(pS->GetName()); - aStr.append(" and Attribute "); - aStr.append(rAttr.GetName()); - aStr.append(" with equal id's"); - rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken()); - rBase.WriteError( rInStm ); + OString aStr = "Attribute " + pS->GetName() + " and Attribute " + rAttr.GetName() + " with equal id's"; + rBase.SetAndWriteError(rInStm, aStr); return false; } } diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index 7ed275f9bd27..49ab9cd67a30 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -292,11 +292,9 @@ void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase, { return; } - rBase.SetError( "the SlotType is not a item", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "the SlotType is not a item" ); } - rBase.SetError( "SlotType with unknown item type", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "SlotType with unknown item type" ); } } rInStm.Seek( nTokPos ); @@ -335,8 +333,7 @@ bool SvMetaSlot::Test( SvIdlDataBase & rBase, SvTokenStream & rInStm ) pType = pType->GetReturnType(); if( !pType->IsItem() ) { - rBase.SetError( "this attribute is not a slot", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "this attribute is not a slot" ); bOk = false; } } @@ -362,11 +359,7 @@ bool SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) } else { - OStringBuffer aStr( "attribute " ); - aStr.append(pAttr->GetName()); - aStr.append(" is method or variable but not a slot"); - rBase.SetError( aStr.makeStringAndClear(), rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "attribute " + pAttr->GetName() + " is method or variable but not a slot" ); bOk = false; } } @@ -395,11 +388,7 @@ bool SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) } else { - OStringBuffer aStr("attribute "); - aStr.append(pAttr2->GetName()); - aStr.append(" is method or variable but not a slot"); - rBase.SetError( aStr.makeStringAndClear(), rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "attribute " + pAttr2->GetName() + " is method or variable but not a slot" ); bOk = false; } } diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index b171fbd64ea8..50fe11bd20f4 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -56,8 +56,7 @@ bool SvMetaAttribute::Test( SvIdlDataBase & rBase, bool bOk = true; if( GetType()->IsItem() && !GetSlotId().IsSet() ) { - rBase.SetError( "slot without id declared", rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "slot without id declared" ); bOk = false; } return bOk; @@ -208,9 +207,7 @@ bool SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase, } else { - OString aStr("wrong typedef: "); - rBase.SetError( aStr, rInStm.GetToken() ); - rBase.WriteError( rInStm ); + rBase.SetAndWriteError( rInStm, "wrong typedef: "); } } if( !bOk ) diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 5e10fc7bd730..03c82c246f1b 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -85,6 +85,12 @@ void SvIdlDataBase::SetError( const OString& rError, SvToken& rTok ) } } +void SvIdlDataBase::SetAndWriteError( SvTokenStream & rInStm, const OString& rError ) +{ + SetError( rError, rInStm.GetToken() ); + WriteError( rInStm ); +} + void SvIdlDataBase::Push( SvMetaObject * pObj ) { GetStack().push_back( pObj ); |