1
+ #include " exceptions.h"
2
+ #include " utilities.h"
3
+
4
+ inline jint throwJavaException (JNIEnv *env, const char *className, std::string &msg) {
5
+ jclass exClass = env->FindClass (className);
6
+ return env->ThrowNew (exClass, msg.c_str ());
7
+ }
8
+
9
+ jint processOpenTimeErrorStatus (JNIEnv *env, opentime::ErrorStatus &errorStatus) {
10
+ switch (errorStatus.outcome ) {
11
+ case opentime::ErrorStatus::Outcome::INVALID_TIMECODE_RATE:
12
+ return throwJavaException (env, " io/opentimeline/opentime/exception/InvalidTimecodeRateException" ,
13
+ errorStatus.details );
14
+ case opentime::ErrorStatus::Outcome::INVALID_TIMECODE_STRING:
15
+ return throwJavaException (env, " io/opentimeline/opentime/exception/InvalidTimecodeStringException" ,
16
+ errorStatus.details );
17
+ case opentime::ErrorStatus::Outcome::INVALID_TIME_STRING:
18
+ return throwJavaException (env, " io/opentimeline/opentime/exception/InvalidTimestringException" ,
19
+ errorStatus.details );
20
+ case opentime::ErrorStatus::Outcome::INVALID_RATE_FOR_DROP_FRAME_TIMECODE:
21
+ return throwJavaException (env,
22
+ " io/opentimeline/opentime/exception/InvalidRateForDropFrameTimecodeException" ,
23
+ errorStatus.details );
24
+ case opentime::ErrorStatus::Outcome::NON_DROPFRAME_RATE:
25
+ return throwJavaException (env, " io/opentimeline/opentime/exception/NonDropframeRateException" ,
26
+ errorStatus.details );
27
+ case opentime::ErrorStatus::Outcome::TIMECODE_RATE_MISMATCH:
28
+ return throwJavaException (env, " io/opentimeline/opentime/exception/TimecodeRateMismatchException" ,
29
+ errorStatus.details );
30
+ case opentime::ErrorStatus::Outcome::NEGATIVE_VALUE: {
31
+ return throwJavaException (env, " io/opentimeline/opentime/exception/NegativeValueException" ,
32
+ errorStatus.details );
33
+ }
34
+ case opentime::ErrorStatus::Outcome::OK:
35
+ return 0 ;
36
+ default : {
37
+ return throwJavaException (env, " io/opentimeline/opentime/exception/OpentimeException" ,
38
+ errorStatus.details );
39
+ }
40
+ }
41
+ }
42
+
43
+ jint processOTIOErrorStatus (JNIEnv *env, OTIO_NS::ErrorStatus &errorStatus) {
44
+ switch (errorStatus.outcome ) {
45
+ case OTIO_NS::ErrorStatus::Outcome::NOT_IMPLEMENTED: {
46
+ return throwJavaException (env, " java/lang/UnsupportedOperationException" ,
47
+ errorStatus.full_description );
48
+ }
49
+ case OTIO_NS::ErrorStatus::Outcome::TYPE_MISMATCH: {
50
+ return throwJavaException (env, " io/opentimeline/opentimelineio/exception/TypeMismatchException" ,
51
+ errorStatus.full_description );
52
+ }
53
+ case OTIO_NS::ErrorStatus::Outcome::FILE_OPEN_FAILED:
54
+ case OTIO_NS::ErrorStatus::Outcome::FILE_WRITE_FAILED: {
55
+ return throwJavaException (env, " java/io/IOException" ,
56
+ errorStatus.full_description );
57
+ }
58
+ case OTIO_NS::ErrorStatus::Outcome::INTERNAL_ERROR:
59
+ case OTIO_NS::ErrorStatus::Outcome::KEY_NOT_FOUND: {
60
+ return throwJavaException (env, " io/opentimeline/opentimelineio/exception/DeserializationException" ,
61
+ errorStatus.full_description );
62
+ }
63
+ case OTIO_NS::ErrorStatus::Outcome::ILLEGAL_INDEX: {
64
+ return throwJavaException (env, " java/lang/IndexOutOfBoundsException" ,
65
+ errorStatus.full_description );
66
+ }
67
+ case OTIO_NS::ErrorStatus::Outcome::MALFORMED_SCHEMA: {
68
+ return throwJavaException (env,
69
+ " io/opentimeline/opentimelineio/exception/MalformedSchemaException" ,
70
+ errorStatus.full_description );
71
+ }
72
+ case OTIO_NS::ErrorStatus::Outcome::JSON_PARSE_ERROR: {
73
+ return throwJavaException (env, " io/opentimeline/opentimelineio/exception/JSONParseException" ,
74
+ errorStatus.full_description );
75
+ }
76
+ case OTIO_NS::ErrorStatus::Outcome::CANNOT_COMPUTE_AVAILABLE_RANGE: {
77
+ return throwJavaException (env,
78
+ " io/opentimeline/opentimelineio/exception/CannotComputeAvailableRangeException" ,
79
+ errorStatus.full_description );
80
+ }
81
+ case OTIO_NS::ErrorStatus::Outcome::INVALID_TIME_RANGE: {
82
+ return throwJavaException (env,
83
+ " io/opentimeline/opentimelineio/exception/InvalidTimeRangeException" ,
84
+ errorStatus.full_description );
85
+ }
86
+ case OTIO_NS::ErrorStatus::Outcome::OBJECT_WITHOUT_DURATION: {
87
+ const char *className = " io/opentimeline/opentimelineio/exception/ObjectWithoutDurationException" ;
88
+ jclass exClass = env->FindClass (className);
89
+ jmethodID exceptionCtor = env->GetMethodID (exClass, " <init>" ,
90
+ " (Ljava/lang/String;Lio/opentimeline/opentimelineio/SerializableObject;)V" );
91
+ jobject exObject = env->NewObject (exClass, exceptionCtor, errorStatus.details .c_str (),
92
+ serializableObjectFromNative (env,
93
+ const_cast <SerializableObject *>(errorStatus.object_details )));
94
+ return env->Throw ((jthrowable) exObject);
95
+ }
96
+ case OTIO_NS::ErrorStatus::Outcome::CANNOT_TRIM_TRANSITION: {
97
+ return throwJavaException (env,
98
+ " io/opentimeline/opentimelineio/exception/TransitionTrimException" ,
99
+ errorStatus.full_description );
100
+ }
101
+ case OTIO_NS::ErrorStatus::Outcome::CHILD_ALREADY_PARENTED: {
102
+ return throwJavaException (env,
103
+ " io/opentimeline/opentimelineio/exception/ChildAlreadyParentedException" ,
104
+ errorStatus.full_description );
105
+ }
106
+ case OTIO_NS::ErrorStatus::Outcome::NOT_A_CHILD_OF:
107
+ case OTIO_NS::ErrorStatus::Outcome::NOT_A_CHILD:
108
+ case OTIO_NS::ErrorStatus::Outcome::NOT_DESCENDED_FROM: {
109
+ return throwJavaException (env,
110
+ " io/opentimeline/opentimelineio/exception/NotAChildException" ,
111
+ errorStatus.full_description );
112
+ }
113
+ case OTIO_NS::ErrorStatus::Outcome::OK:
114
+ return 0 ;
115
+ case OTIO_NS::ErrorStatus::Outcome::SCHEMA_ALREADY_REGISTERED:
116
+ case OTIO_NS::ErrorStatus::Outcome::SCHEMA_NOT_REGISTERED:
117
+ case OTIO_NS::ErrorStatus::Outcome::SCHEMA_VERSION_UNSUPPORTED:
118
+ case OTIO_NS::ErrorStatus::Outcome::NOT_AN_ITEM:
119
+ case OTIO_NS::ErrorStatus::Outcome::UNRESOLVED_OBJECT_REFERENCE:
120
+ case OTIO_NS::ErrorStatus::Outcome::DUPLICATE_OBJECT_REFERENCE: {
121
+ return throwJavaException (env,
122
+ " io/opentimeline/opentimelineio/exception/OpenTimelineIOException" ,
123
+ errorStatus.full_description );
124
+ }
125
+ default : {
126
+ return throwJavaException (env,
127
+ " io/opentimeline/opentimelineio/exception/OpenTimelineIOException" ,
128
+ errorStatus.full_description );
129
+ }
130
+ }
131
+ }
0 commit comments