From 9135fe36f5c9174a1aa2d339bb0b3c7dd08ff704 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Wed, 13 Feb 2013 16:48:11 +0000 Subject: [PATCH] [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 --- pykd/typeinfo.cpp | 8 ++++---- pykd/typeinfo.h | 1 + pykd/udtutils.cpp | 5 ++++- pykd/udtutils.h | 5 +++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 6984ef6..64fa31a 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -850,12 +850,12 @@ TypeInfoPtr EnumTypeInfo::getField( const std::string &fieldName ) TypeInfoPtr EnumTypeInfo::getFieldByIndex( ULONG index ) { 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); 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() ); } @@ -865,12 +865,12 @@ TypeInfoPtr EnumTypeInfo::getFieldByIndex( ULONG index ) std::string EnumTypeInfo::getFieldNameByIndex( ULONG index ) { 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); if ( !field ) - throw TypeException( m_dia->getName(), ": field not found" ); + throw PyException( PyExc_IndexError, "index out of range" ); return field->getName(); } diff --git a/pykd/typeinfo.h b/pykd/typeinfo.h index 9878b20..87c455f 100644 --- a/pykd/typeinfo.h +++ b/pykd/typeinfo.h @@ -407,6 +407,7 @@ protected: protected: UdtTypeInfoBase(const std::string &typeName) : + m_fields(typeName), m_name(typeName), m_fieldsGot( false ) {} diff --git a/pykd/udtutils.cpp b/pykd/udtutils.cpp index 90d61e9..a9654e3 100644 --- a/pykd/udtutils.cpp +++ b/pykd/udtutils.cpp @@ -32,7 +32,10 @@ const UdtFieldPtr& FieldCollection::lookup(const std::string &name) const return *it; } - throw TypeException( "", "field not found" ); + std::stringstream sstr; + sstr << "field \"" << name << " not found"; + + throw TypeException( m_name, sstr.str() ); } ///////////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/udtutils.h b/pykd/udtutils.h index a33a4d5..07683e5 100644 --- a/pykd/udtutils.h +++ b/pykd/udtutils.h @@ -161,6 +161,10 @@ class FieldCollection { public: + FieldCollection( const std::string &name ) : + m_name( name ) + {} + const UdtFieldPtr &lookup(ULONG index) const; const UdtFieldPtr &lookup(const std::string &name) const; @@ -179,6 +183,7 @@ private: typedef std::vector FieldList; FieldList m_fields; + std::string m_name; }; ///////////////////////////////////////////////////////////////////////////////////