C++ plugin exceptions correctly handled now
This commit is contained in:
parent
d719282aaf
commit
b939f3bc2f
|
@ -44,6 +44,25 @@
|
||||||
|
|
||||||
%rename(AddNative) *::Add;
|
%rename(AddNative) *::Add;
|
||||||
|
|
||||||
|
%exception {
|
||||||
|
try{
|
||||||
|
$action
|
||||||
|
}
|
||||||
|
catch( IO_ERROR e )
|
||||||
|
{
|
||||||
|
char ExceptionError[256];
|
||||||
|
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
|
||||||
|
PyErr_SetString(PyExc_IOError,ExceptionError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
SWIG_fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%include exception.i
|
||||||
|
|
||||||
|
|
||||||
// this is what it must be included in the wrapper .cxx code to compile
|
// this is what it must be included in the wrapper .cxx code to compile
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
|
@ -67,16 +67,8 @@ BOARD* LoadBoard(wxString& aFileName)
|
||||||
|
|
||||||
BOARD* LoadBoard(wxString& aFileName,IO_MGR::PCB_FILE_T aFormat)
|
BOARD* LoadBoard(wxString& aFileName,IO_MGR::PCB_FILE_T aFormat)
|
||||||
{
|
{
|
||||||
static char ExceptionError[256];
|
return IO_MGR::Load(aFormat,aFileName);
|
||||||
try{
|
|
||||||
return IO_MGR::Load(aFormat,aFileName);
|
|
||||||
} catch (IO_ERROR e)
|
|
||||||
{
|
|
||||||
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
|
|
||||||
PyErr_SetString(PyExc_IOError,ExceptionError);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveBoard(wxString& aFilename, BOARD* aBoard)
|
bool SaveBoard(wxString& aFilename, BOARD* aBoard)
|
||||||
|
@ -87,7 +79,6 @@ bool SaveBoard(wxString& aFilename, BOARD* aBoard)
|
||||||
bool SaveBoard(wxString& aFileName, BOARD* aBoard,
|
bool SaveBoard(wxString& aFileName, BOARD* aBoard,
|
||||||
IO_MGR::PCB_FILE_T aFormat)
|
IO_MGR::PCB_FILE_T aFormat)
|
||||||
{
|
{
|
||||||
static char ExceptionError[256];
|
|
||||||
aBoard->m_Status_Pcb &= ~CONNEXION_OK;
|
aBoard->m_Status_Pcb &= ~CONNEXION_OK;
|
||||||
aBoard->SynchronizeNetsAndNetClasses();
|
aBoard->SynchronizeNetsAndNetClasses();
|
||||||
aBoard->SetCurrentNetClass( aBoard->m_NetClasses.GetDefault()->GetName() );
|
aBoard->SetCurrentNetClass( aBoard->m_NetClasses.GetDefault()->GetName() );
|
||||||
|
@ -105,19 +96,10 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
IO_MGR::Save( aFormat, aFileName, aBoard, &props );
|
||||||
IO_MGR::Save( aFormat, aFileName, aBoard, &props );
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (IO_ERROR e)
|
|
||||||
{
|
|
||||||
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
|
|
||||||
PyErr_SetString(PyExc_IOError,ExceptionError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue