File: JavaExceptionTypemaps.i

package info (click to toggle)
robotraconteur 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,380 kB
  • sloc: cpp: 1,149,268; cs: 87,653; java: 58,127; python: 26,897; ansic: 356; sh: 152; makefile: 90; xml: 51
file content (65 lines) | stat: -rw-r--r-- 1,589 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

%exception {
try
{
  $action
  }
  catch (RobotRaconteur::RobotRaconteurException& e)
  {

	jclass clazz2;
	jmethodID mid2;
	jthrowable jexp;
	jlong error_info_ptr=0;
    RobotRaconteur::HandlerErrorInfo error_info(e);
	clazz2=jenv->FindClass("com/robotraconteur/RobotRaconteurExceptionUtil");
	if (!clazz2) goto rrerrfail;
	mid2 = jenv->GetStaticMethodID(clazz2, "errorInfoToException" ,"(J)Ljava/lang/RuntimeException;");
	if (!mid2) goto rrerrfail;
	error_info_ptr=(jlong)&error_info;
	jexp=(jthrowable)jenv->CallStaticObjectMethod(clazz2,mid2,error_info_ptr);
	jenv->Throw(jexp);
	return $null;

	rrerrfail:
		jclass clazz = jenv->FindClass( "java/lang/RuntimeException");
		jenv->ThrowNew(clazz, e.what());
		return $null;


  }
  catch (std::exception& e) {
    jclass clazz = jenv->FindClass( "java/lang/RuntimeException");
    jenv->ThrowNew(clazz, e.what());
    return $null;
  }
}

%rr_intrusive_ptr(RobotRaconteur::MessageEntry)

//RRDirectorExceptionHelper

%typemap(javacode) RobotRaconteur::RRDirectorExceptionHelper %{
public static String exceptionToStackTraceString(Exception exp)
{
	java.io.StringWriter sw = new java.io.StringWriter();
	java.io.PrintWriter pw = new java.io.PrintWriter(sw);
	exp.printStackTrace(pw);
	return sw.toString();
}
%}

namespace RobotRaconteur {
class RRDirectorExceptionHelper
{


public:
	static void Reset();
	static void SetError(const boost::intrusive_ptr<RobotRaconteur::MessageEntry>& err, const std::string& exception_str);
	static bool IsErrorPending();
	static boost::intrusive_ptr<RobotRaconteur::MessageEntry> GetError();

};

}