Add std::bad_cast to std_except.i
This exception occurs when dynamic_cast<T&> fails. Fixes #783.
This commit is contained in:
parent
b138f054e5
commit
2dc87d7485
9 changed files with 12 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ public class li_std_except_runme {
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
Test test = new Test();
|
Test test = new Test();
|
||||||
|
try { test.throw_bad_cast(); throw new Exception("throw_bad_cast failed"); } catch (InvalidCastException) {}
|
||||||
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
|
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
|
||||||
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
|
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
|
||||||
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
|
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
int foo3() throw(E1) { return 0; }
|
int foo3() throw(E1) { return 0; }
|
||||||
int foo4() throw(E2) { return 0; }
|
int foo4() throw(E2) { return 0; }
|
||||||
// all the STL exceptions...
|
// all the STL exceptions...
|
||||||
|
void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); }
|
||||||
void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
|
void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
|
||||||
void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
|
void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
|
||||||
void throw_exception() throw(std::exception) { throw std::exception(); }
|
void throw_exception() throw(std::exception) { throw std::exception(); }
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws, canthrow=1) std::bad_cast "SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws, canthrow=1) std::bad_cast "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws) std::bad_cast %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws) std::bad_cast "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ namespace std
|
||||||
// normally objects which are thrown are returned to the interpreter as errors
|
// normally objects which are thrown are returned to the interpreter as errors
|
||||||
// (which potentially may have problems if they are not copied)
|
// (which potentially may have problems if they are not copied)
|
||||||
// therefore all classes based upon std::exception are converted to their strings & returned as errors
|
// therefore all classes based upon std::exception are converted to their strings & returned as errors
|
||||||
|
%typemap(throws) std::bad_cast "SWIG_exception(SWIG_TypeError, $1.what());"
|
||||||
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
|
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
|
||||||
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
||||||
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"
|
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ namespace std {
|
||||||
virtual const char* what() const throw();
|
virtual const char* what() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bad_cast : exception
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
struct bad_exception : exception
|
struct bad_exception : exception
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
%std_exception_map(bad_cast, SWIG_TypeError);
|
||||||
%std_exception_map(bad_exception, SWIG_SystemError);
|
%std_exception_map(bad_exception, SWIG_SystemError);
|
||||||
%std_exception_map(domain_error, SWIG_ValueError);
|
%std_exception_map(domain_error, SWIG_ValueError);
|
||||||
%std_exception_map(exception, SWIG_SystemError);
|
%std_exception_map(exception, SWIG_SystemError);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue