summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2003-12-17 17:46:50 +0000
committerVladimir Glazounov <vg@openoffice.org>2003-12-17 17:46:50 +0000
commit874eb2fb8fd6105ba77eba3239b5907653a54086 (patch)
tree4b4175dabe3e65215ec3836a8bf7e92747044e34 /pyuno
parent7129fcc90e2c0c0e582477e07ad5acea26f75798 (diff)
INTEGRATION: CWS geordi2q11 (1.4.8); FILE MERGED
2003/12/16 14:04:30 hr 1.4.8.1: #111934#: join CWS ooo111fix1
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx85
1 files changed, 83 insertions, 2 deletions
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 8bc32bc0dbd1..1d1c9a38407f 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pyuno_runtime.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hjs $ $Date: 2003-08-18 15:01:58 $
+ * last change: $Author: vg $ $Date: 2003-12-17 18:46:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -829,6 +829,87 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
return a;
}
+Any Runtime::extractUnoException( const PyRef & excType, const PyRef &excValue, const PyRef &excTraceback) const
+{
+ PyRef str;
+ Any ret;
+ if( excTraceback.is() )
+ {
+ PyRef unoModule( impl ? impl->cargo->getUnoModule() : 0 );
+ if( unoModule.is() )
+ {
+ PyRef extractTraceback(
+ PyDict_GetItemString(unoModule.get(),"_uno_extract_printable_stacktrace" ) );
+
+ if( extractTraceback.is() )
+ {
+ PyRef args( PyTuple_New( 1), SAL_NO_ACQUIRE );
+ PyTuple_SetItem( args.get(), 0, excTraceback.getAcquired() );
+ str = PyRef( PyObject_CallObject( extractTraceback.get(),args.get() ), SAL_NO_ACQUIRE);
+ }
+ else
+ {
+ str = PyRef(
+ PyString_FromString( "Couldn't find uno._uno_extract_printable_stacktrace" ),
+ SAL_NO_ACQUIRE );
+ }
+ }
+ else
+ {
+ str = PyRef(
+ PyString_FromString( "Couldn't find uno.py, no stacktrace available" ),
+ SAL_NO_ACQUIRE );
+ }
+
+ }
+ else
+ {
+ // it may occur, that no traceback is given (e.g. only native code below)
+ str = PyRef( PyString_FromString( "no traceback available" ), SAL_NO_ACQUIRE);
+ }
+
+ if( isInstanceOfStructOrException( *this, excValue.get() ) )
+ {
+ ret = pyObject2Any( excValue );
+ }
+ else
+ {
+ OUStringBuffer buf;
+ PyRef typeName( PyObject_Str( excType.get() ), SAL_NO_ACQUIRE );
+ if( typeName.is() )
+ {
+ buf.appendAscii( PyString_AsString( typeName.get() ) );
+ }
+ else
+ {
+ buf.appendAscii( "no typename available" );
+ }
+ buf.appendAscii( ": " );
+ PyRef valueRep( PyObject_Str( excValue.get() ), SAL_NO_ACQUIRE );
+ if( valueRep.is() )
+ {
+ buf.appendAscii( PyString_AsString( valueRep.get()));
+ }
+ else
+ {
+ buf.appendAscii( "Couldn't convert exception value to a string" );
+ }
+ buf.appendAscii( ", traceback follows\n" );
+ if( str.is() )
+ {
+ buf.appendAscii( PyString_AsString( str.get() ) );
+ }
+ else
+ {
+ buf.appendAscii( ", no traceback available\n" );
+ }
+ RuntimeException e;
+ e.Message = buf.makeStringAndClear();
+ ret = com::sun::star::uno::makeAny( e );
+ }
+ return ret;
+}
+
PyThreadAttach::PyThreadAttach( PyInterpreterState *interp)
throw ( com::sun::star::uno::RuntimeException )