Commit b939f3bc authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

C++ plugin exceptions correctly handled now

parent d719282a
......@@ -44,6 +44,25 @@
%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
%{
......
......@@ -67,15 +67,7 @@ BOARD* LoadBoard(wxString& aFileName)
BOARD* LoadBoard(wxString& aFileName,IO_MGR::PCB_FILE_T aFormat)
{
static char ExceptionError[256];
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;
}
}
......@@ -87,7 +79,6 @@ bool SaveBoard(wxString& aFilename, BOARD* aBoard)
bool SaveBoard(wxString& aFileName, BOARD* aBoard,
IO_MGR::PCB_FILE_T aFormat)
{
static char ExceptionError[256];
aBoard->m_Status_Pcb &= ~CONNEXION_OK;
aBoard->SynchronizeNetsAndNetClasses();
aBoard->SetCurrentNetClass( aBoard->m_NetClasses.GetDefault()->GetName() );
......@@ -105,18 +96,9 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard,
}
try
{
IO_MGR::Save( aFormat, aFileName, aBoard, &props );
return true;
}
catch (IO_ERROR e)
{
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
PyErr_SetString(PyExc_IOError,ExceptionError);
return false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment