From: Michael H. <mic...@gm...> - 2010-11-07 06:25:08
|
Hello, I'm new to SWIG and I've been playing with the examples in the documentation, but I've been having some problem with exceptions. I want to translate my C++ exception to a custom checked Java exception. I've followed the example in the documentation, but I can't get FileException to extend java.lang.Exception. I have everything in the .i file. I'm using swig version 2.0.1 (the latest). Here's my interface file: /*Example.i*/ %module example %include "std_string.i" #include <string> class SimpleFile { std::string filename; public: SimpleFile(const std::string& filename) : filename(filename) {} void open() throw(FileException) { std::cout << "Something bad can happen..." << std::endl; } }; class FileException { std::string message; public: FileException(const std::string& msg) : message(msg) {} std::string what() { return message; } }; %typemap(javabase) FileException "java.lang.Exception"; %typemap(javacode) FileException %{ public String getMessage() { return what(); } %} How can I get FileException to extend java.lang.Exception? Thank you very much! |