[0.2.x] added : added field name for TypeException "field not found"

git-svn-id: https://pykd.svn.codeplex.com/svn@82636 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2013-02-13 16:48:11 +00:00 committed by Mikhail I. Izmestev
parent a69089a004
commit 9135fe36f5
4 changed files with 14 additions and 5 deletions

View File

@ -850,12 +850,12 @@ TypeInfoPtr EnumTypeInfo::getField( const std::string &fieldName )
TypeInfoPtr EnumTypeInfo::getFieldByIndex( ULONG index ) TypeInfoPtr EnumTypeInfo::getFieldByIndex( ULONG index )
{ {
if ( index >= m_dia->getChildCount() ) if ( index >= m_dia->getChildCount() )
throw TypeException( m_dia->getName(), ": field not found" ); throw PyException( PyExc_IndexError, "index out of range" );
SymbolPtr field = m_dia->getChildByIndex(index); SymbolPtr field = m_dia->getChildByIndex(index);
if ( !field ) if ( !field )
throw TypeException( m_dia->getName(), ": field not found" ); throw PyException( PyExc_IndexError, "index out of range" );
return TypeInfo::getTypeInfo( m_dia, field->getName() ); return TypeInfo::getTypeInfo( m_dia, field->getName() );
} }
@ -865,12 +865,12 @@ TypeInfoPtr EnumTypeInfo::getFieldByIndex( ULONG index )
std::string EnumTypeInfo::getFieldNameByIndex( ULONG index ) std::string EnumTypeInfo::getFieldNameByIndex( ULONG index )
{ {
if ( index >= m_dia->getChildCount() ) if ( index >= m_dia->getChildCount() )
throw TypeException( m_dia->getName(), ": field not found" ); throw PyException( PyExc_IndexError, "index out of range" );
SymbolPtr field = m_dia->getChildByIndex(index); SymbolPtr field = m_dia->getChildByIndex(index);
if ( !field ) if ( !field )
throw TypeException( m_dia->getName(), ": field not found" ); throw PyException( PyExc_IndexError, "index out of range" );
return field->getName(); return field->getName();
} }

View File

@ -407,6 +407,7 @@ protected:
protected: protected:
UdtTypeInfoBase(const std::string &typeName) : UdtTypeInfoBase(const std::string &typeName) :
m_fields(typeName),
m_name(typeName), m_name(typeName),
m_fieldsGot( false ) m_fieldsGot( false )
{} {}

View File

@ -32,7 +32,10 @@ const UdtFieldPtr& FieldCollection::lookup(const std::string &name) const
return *it; return *it;
} }
throw TypeException( "", "field not found" ); std::stringstream sstr;
sstr << "field \"" << name << " not found";
throw TypeException( m_name, sstr.str() );
} }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////

View File

@ -161,6 +161,10 @@ class FieldCollection
{ {
public: public:
FieldCollection( const std::string &name ) :
m_name( name )
{}
const UdtFieldPtr &lookup(ULONG index) const; const UdtFieldPtr &lookup(ULONG index) const;
const UdtFieldPtr &lookup(const std::string &name) const; const UdtFieldPtr &lookup(const std::string &name) const;
@ -179,6 +183,7 @@ private:
typedef std::vector<UdtFieldPtr> FieldList; typedef std::vector<UdtFieldPtr> FieldList;
FieldList m_fields; FieldList m_fields;
std::string m_name;
}; };
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////