summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-15 17:51:20 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2019-01-15 17:51:20 +0900
commite2589e3b48c4d05db198f7729708ac8bca6f42be (patch)
treefd26c306953a1cf97cd8fd1ea5b7267cbc51d509 /src
parent130fe0bf7829d1bd8caae4df084c2975ff246a64 (diff)
efl-mono: Only raise exception for managed errors.
Summary: Previously, any unhandled Eina_Error would cause an exception to be thrown when the control returned to C#. This commit changes this behavior to only raise it when an exception went unhandled from a C# callback back to C, like in an event handler, for example. Test Plan: run tests Reviewers: segfaultxavi, Jaehyun_Cho, felipealmeida Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7537
Diffstat (limited to 'src')
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_helpers.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh6
-rw-r--r--src/bindings/mono/eina_mono/eina_error.cs15
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_common.cs6
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_connection.cs27
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_message.cs43
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_object.cs24
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_proxy.cs12
-rw-r--r--src/examples/eina/EinaError01.cs4
-rw-r--r--src/tests/efl_mono/Errors.cs19
13 files changed, 21 insertions, 143 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 22849a9..c9cb686 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -264,7 +264,7 @@ struct event_definition_generator
264 << scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n" 264 << scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n"
265 << scope_tab << scope_tab << "} catch (Exception e) {\n" 265 << scope_tab << scope_tab << "} catch (Exception e) {\n"
266 << scope_tab << scope_tab << scope_tab << "Eina.Log.Error(e.ToString());\n" 266 << scope_tab << scope_tab << scope_tab << "Eina.Log.Error(e.ToString());\n"
267 << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n" 267 << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
268 << scope_tab << scope_tab << "}\n" 268 << scope_tab << scope_tab << "}\n"
269 << scope_tab << "}\n\n" 269 << scope_tab << "}\n\n"
270 ).generate(sink, attributes::unused, context)) 270 ).generate(sink, attributes::unused, context))
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index b0e2e5e..763bbc4 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -93,7 +93,7 @@ struct native_function_definition_generator
93 << "(" << (native_argument_invocation % ", ") << ");\n" 93 << "(" << (native_argument_invocation % ", ") << ");\n"
94 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 94 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
95 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 95 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
96 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n" 96 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
97 << scope_tab << scope_tab << scope_tab << "}\n" 97 << scope_tab << scope_tab << scope_tab << "}\n"
98 << eolian_mono::native_function_definition_epilogue(*klass) 98 << eolian_mono::native_function_definition_epilogue(*klass)
99 << scope_tab << scope_tab << "} else {\n" 99 << scope_tab << scope_tab << "} else {\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_helpers.hh b/src/bin/eolian_mono/eolian/mono/function_helpers.hh
index 017ddad..c83cbbb 100644
--- a/src/bin/eolian_mono/eolian/mono/function_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_helpers.hh
@@ -99,7 +99,7 @@ struct function_definition_epilogue_generator
99 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 99 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
100 { 100 {
101 if (!as_generator( 101 if (!as_generator(
102 scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n" 102 scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
103 << *(scope_tab << scope_tab << convert_out_assign) 103 << *(scope_tab << scope_tab << convert_out_assign)
104 << *(scope_tab << scope_tab << convert_in_ptr_assign) 104 << *(scope_tab << scope_tab << convert_in_ptr_assign)
105 << scope_tab << scope_tab << convert_return 105 << scope_tab << scope_tab << convert_return
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 95c0e0f..2c62abe 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -90,7 +90,7 @@ struct function_pointer {
90 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n" 90 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
91 << scope_tab << scope_tab << "} catch (Exception e) {\n" 91 << scope_tab << scope_tab << "} catch (Exception e) {\n"
92 << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 92 << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
93 << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n" 93 << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
94 << scope_tab << scope_tab << "}\n" 94 << scope_tab << scope_tab << "}\n"
95 << native_function_definition_epilogue(nullptr) 95 << native_function_definition_epilogue(nullptr)
96 << scope_tab << "}\n" 96 << scope_tab << "}\n"
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 907ac97..a22a5a0 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -579,7 +579,7 @@ struct klass
579 << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.data_set(this);\n" 579 << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.data_set(this);\n"
580 << scope_tab << scope_tab << "}\n" 580 << scope_tab << scope_tab << "}\n"
581 << scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_end(handle);\n" 581 << scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_end(handle);\n"
582 << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n" 582 << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
583 << scope_tab << "}\n" 583 << scope_tab << "}\n"
584 584
585 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n" 585 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
@@ -718,7 +718,7 @@ struct klass
718 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to add event proxy for event {key}\");\n" 718 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
719 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 719 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
720 << scope_tab << scope_tab << scope_tab << "}\n" 720 << scope_tab << scope_tab << scope_tab << "}\n"
721 << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n" 721 << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
722 << scope_tab << scope_tab << "} \n" 722 << scope_tab << scope_tab << "} \n"
723 << scope_tab << scope_tab << "event_cb_count[key]++;\n" 723 << scope_tab << scope_tab << "event_cb_count[key]++;\n"
724 << scope_tab << scope_tab << "return true;\n" 724 << scope_tab << scope_tab << "return true;\n"
@@ -740,7 +740,7 @@ struct klass
740 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n" 740 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
741 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 741 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
742 << scope_tab << scope_tab << scope_tab << "}\n" 742 << scope_tab << scope_tab << scope_tab << "}\n"
743 << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n" 743 << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
744 << scope_tab << scope_tab << "} else if (event_count == 0) {\n" 744 << scope_tab << scope_tab << "} else if (event_count == 0) {\n"
745 << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n" 745 << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n"
746 << scope_tab << scope_tab << scope_tab << "return false;\n" 746 << scope_tab << scope_tab << scope_tab << "return false;\n"
diff --git a/src/bindings/mono/eina_mono/eina_error.cs b/src/bindings/mono/eina_mono/eina_error.cs
index 00e8f91..c2027ae 100644
--- a/src/bindings/mono/eina_mono/eina_error.cs
+++ b/src/bindings/mono/eina_mono/eina_error.cs
@@ -14,7 +14,7 @@ public struct Error : IComparable<Error>
14 get { return MsgGet(this); } 14 get { return MsgGet(this); }
15 } 15 }
16 16
17 public static Error EFL_ERROR; 17 public static Error UNHANDLED_EXCEPTION;
18 18
19 public static Error NO_ERROR = new Error(0); 19 public static Error NO_ERROR = new Error(0);
20 public static Error EPERM = new Error(1); 20 public static Error EPERM = new Error(1);
@@ -41,7 +41,7 @@ public struct Error : IComparable<Error>
41 41
42 internal static void Init() 42 internal static void Init()
43 { 43 {
44 EFL_ERROR = eina_error_msg_register("Managed Code Error"); 44 UNHANDLED_EXCEPTION = eina_error_msg_register("Unhandled C# exception occurred.");
45 } 45 }
46 46
47 [DllImport(efl.Libs.Eina)] static extern Error eina_error_msg_register(string msg); 47 [DllImport(efl.Libs.Eina)] static extern Error eina_error_msg_register(string msg);
@@ -65,11 +65,16 @@ public struct Error : IComparable<Error>
65 return Eina.StringConversion.NativeUtf8ToManagedString(cstr); 65 return Eina.StringConversion.NativeUtf8ToManagedString(cstr);
66 } 66 }
67 67
68 public static void RaiseIfOccurred() 68 /// <summary>Raises an exception if an unhandled exception occurred before switching
69 /// back to the native code. For example, in an event handler.</summary>
70 public static void RaiseIfUnhandledException()
69 { 71 {
70 Error e = Get(); 72 Error e = Get();
71 Clear(); 73 if (e == UNHANDLED_EXCEPTION)
72 Raise(e); 74 {
75 Clear();
76 Raise(e);
77 }
73 } 78 }
74 79
75 public static void Raise(Error e) 80 public static void Raise(Error e)
diff --git a/src/bindings/mono/eldbus_mono/eldbus_common.cs b/src/bindings/mono/eldbus_mono/eldbus_common.cs
index 558bfcf..30e3b0b 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_common.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_common.cs
@@ -135,19 +135,13 @@ public abstract class BasicMessageArgument
135 public void AppendTo(eldbus.Message msg) 135 public void AppendTo(eldbus.Message msg)
136 { 136 {
137 if (!InternalAppendTo(msg)) 137 if (!InternalAppendTo(msg))
138 {
139 Eina.Error.RaiseIfOccurred();
140 throw new SEHException("Eldbus: could not append basic type to eldbus.Message"); 138 throw new SEHException("Eldbus: could not append basic type to eldbus.Message");
141 }
142 } 139 }
143 140
144 public void AppendTo(eldbus.MessageIterator iter) 141 public void AppendTo(eldbus.MessageIterator iter)
145 { 142 {
146 if (!InternalAppendTo(iter)) 143 if (!InternalAppendTo(iter))
147 {
148 Eina.Error.RaiseIfOccurred();
149 throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator"); 144 throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator");
150 }
151 } 145 }
152 146
153 public abstract char TypeCode {get;} 147 public abstract char TypeCode {get;}
diff --git a/src/bindings/mono/eldbus_mono/eldbus_connection.cs b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
index 61ad6b6..099582e 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_connection.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
@@ -192,10 +192,7 @@ public class Connection : IDisposable
192 var pending_hdl = eldbus_connection_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout); 192 var pending_hdl = eldbus_connection_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
193 193
194 if(pending_hdl == IntPtr.Zero) 194 if(pending_hdl == IntPtr.Zero)
195 {
196 Eina.Error.RaiseIfOccurred();
197 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_connection_send"); 195 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_connection_send");
198 }
199 196
200 msg.Ref(); 197 msg.Ref();
201 198
@@ -224,10 +221,7 @@ public class Connection : IDisposable
224 var pending_hdl = eldbus_name_request(Handle, bus, flags, cb_wrapper, cb_data); 221 var pending_hdl = eldbus_name_request(Handle, bus, flags, cb_wrapper, cb_data);
225 222
226 if(pending_hdl == IntPtr.Zero) 223 if(pending_hdl == IntPtr.Zero)
227 {
228 Eina.Error.RaiseIfOccurred();
229 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_request"); 224 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_request");
230 }
231 225
232 return new eldbus.Pending(pending_hdl, false); 226 return new eldbus.Pending(pending_hdl, false);
233 } 227 }
@@ -245,10 +239,7 @@ public class Connection : IDisposable
245 var pending_hdl = eldbus_name_release(Handle, bus, cb_wrapper, cb_data); 239 var pending_hdl = eldbus_name_release(Handle, bus, cb_wrapper, cb_data);
246 240
247 if(pending_hdl == IntPtr.Zero) 241 if(pending_hdl == IntPtr.Zero)
248 {
249 Eina.Error.RaiseIfOccurred();
250 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_release"); 242 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_release");
251 }
252 243
253 return new eldbus.Pending(pending_hdl, false); 244 return new eldbus.Pending(pending_hdl, false);
254 } 245 }
@@ -266,10 +257,7 @@ public class Connection : IDisposable
266 var pending_hdl = eldbus_name_owner_get(Handle, bus, cb_wrapper, cb_data); 257 var pending_hdl = eldbus_name_owner_get(Handle, bus, cb_wrapper, cb_data);
267 258
268 if(pending_hdl == IntPtr.Zero) 259 if(pending_hdl == IntPtr.Zero)
269 {
270 Eina.Error.RaiseIfOccurred();
271 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_get"); 260 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_get");
272 }
273 261
274 return new eldbus.Pending(pending_hdl, false); 262 return new eldbus.Pending(pending_hdl, false);
275 } 263 }
@@ -287,10 +275,7 @@ public class Connection : IDisposable
287 var pending_hdl = eldbus_name_owner_has(Handle, bus, cb_wrapper, cb_data); 275 var pending_hdl = eldbus_name_owner_has(Handle, bus, cb_wrapper, cb_data);
288 276
289 if(pending_hdl == IntPtr.Zero) 277 if(pending_hdl == IntPtr.Zero)
290 {
291 Eina.Error.RaiseIfOccurred();
292 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_has"); 278 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_has");
293 }
294 279
295 return new eldbus.Pending(pending_hdl, false); 280 return new eldbus.Pending(pending_hdl, false);
296 } 281 }
@@ -305,10 +290,7 @@ public class Connection : IDisposable
305 var pending_hdl = eldbus_names_list(Handle, cb_wrapper, cb_data); 290 var pending_hdl = eldbus_names_list(Handle, cb_wrapper, cb_data);
306 291
307 if(pending_hdl == IntPtr.Zero) 292 if(pending_hdl == IntPtr.Zero)
308 {
309 Eina.Error.RaiseIfOccurred();
310 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_list"); 293 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_list");
311 }
312 294
313 return new eldbus.Pending(pending_hdl, false); 295 return new eldbus.Pending(pending_hdl, false);
314 } 296 }
@@ -323,10 +305,7 @@ public class Connection : IDisposable
323 var pending_hdl = eldbus_names_activatable_list(Handle, cb_wrapper, cb_data); 305 var pending_hdl = eldbus_names_activatable_list(Handle, cb_wrapper, cb_data);
324 306
325 if(pending_hdl == IntPtr.Zero) 307 if(pending_hdl == IntPtr.Zero)
326 {
327 Eina.Error.RaiseIfOccurred();
328 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_activatable_list"); 308 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_activatable_list");
329 }
330 309
331 return new eldbus.Pending(pending_hdl, false); 310 return new eldbus.Pending(pending_hdl, false);
332 } 311 }
@@ -341,10 +320,7 @@ public class Connection : IDisposable
341 var pending_hdl = eldbus_hello(Handle, cb_wrapper, cb_data); 320 var pending_hdl = eldbus_hello(Handle, cb_wrapper, cb_data);
342 321
343 if(pending_hdl == IntPtr.Zero) 322 if(pending_hdl == IntPtr.Zero)
344 {
345 Eina.Error.RaiseIfOccurred();
346 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_hello"); 323 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_hello");
347 }
348 324
349 return new eldbus.Pending(pending_hdl, false); 325 return new eldbus.Pending(pending_hdl, false);
350 } 326 }
@@ -362,10 +338,7 @@ public class Connection : IDisposable
362 var pending_hdl = eldbus_name_start(Handle, bus, flags, cb_wrapper, cb_data); 338 var pending_hdl = eldbus_name_start(Handle, bus, flags, cb_wrapper, cb_data);
363 339
364 if(pending_hdl == IntPtr.Zero) 340 if(pending_hdl == IntPtr.Zero)
365 {
366 Eina.Error.RaiseIfOccurred();
367 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_start"); 341 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_start");
368 }
369 342
370 return new eldbus.Pending(pending_hdl, false); 343 return new eldbus.Pending(pending_hdl, false);
371 } 344 }
diff --git a/src/bindings/mono/eldbus_mono/eldbus_message.cs b/src/bindings/mono/eldbus_mono/eldbus_message.cs
index 82fb5da..b3826d6 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_message.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_message.cs
@@ -251,10 +251,7 @@ public class Message : IDisposable
251 { 251 {
252 var ptr = eldbus_message_method_call_new(dest, path, iface, method); 252 var ptr = eldbus_message_method_call_new(dest, path, iface, method);
253 if (ptr == IntPtr.Zero) 253 if (ptr == IntPtr.Zero)
254 {
255 Eina.Error.RaiseIfOccurred();
256 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_call_new"); 254 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_call_new");
257 }
258 return new eldbus.Message(ptr, true); 255 return new eldbus.Message(ptr, true);
259 } 256 }
260 257
@@ -262,10 +259,7 @@ public class Message : IDisposable
262 { 259 {
263 var ptr = eldbus_message_signal_new(path, _interface, name); 260 var ptr = eldbus_message_signal_new(path, _interface, name);
264 if (ptr == IntPtr.Zero) 261 if (ptr == IntPtr.Zero)
265 {
266 Eina.Error.RaiseIfOccurred();
267 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_signal_new"); 262 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_signal_new");
268 }
269 return new eldbus.Message(ptr, true); 263 return new eldbus.Message(ptr, true);
270 } 264 }
271 265
@@ -328,10 +322,7 @@ public class Message : IDisposable
328 CheckHandle(); 322 CheckHandle();
329 var ptr = eldbus_message_error_new(Handle, error_name, error_msg); 323 var ptr = eldbus_message_error_new(Handle, error_name, error_msg);
330 if (ptr == IntPtr.Zero) 324 if (ptr == IntPtr.Zero)
331 {
332 Eina.Error.RaiseIfOccurred();
333 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_error_new"); 325 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_error_new");
334 }
335 return new eldbus.Message(ptr, false); 326 return new eldbus.Message(ptr, false);
336 } 327 }
337 328
@@ -340,10 +331,7 @@ public class Message : IDisposable
340 CheckHandle(); 331 CheckHandle();
341 var ptr = eldbus_message_method_return_new(Handle); 332 var ptr = eldbus_message_method_return_new(Handle);
342 if (ptr == IntPtr.Zero) 333 if (ptr == IntPtr.Zero)
343 {
344 Eina.Error.RaiseIfOccurred();
345 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_return_new"); 334 throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_return_new");
346 }
347 return new eldbus.Message(ptr, false); 335 return new eldbus.Message(ptr, false);
348 } 336 }
349 337
@@ -471,10 +459,7 @@ public class Message : IDisposable
471 CheckHandle(); 459 CheckHandle();
472 var ptr = eldbus_message_iter_get(Handle); 460 var ptr = eldbus_message_iter_get(Handle);
473 if (ptr == IntPtr.Zero) 461 if (ptr == IntPtr.Zero)
474 {
475 Eina.Error.RaiseIfOccurred();
476 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_get"); 462 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_get");
477 }
478 return new eldbus.MessageIterator(ptr, IntPtr.Zero); 463 return new eldbus.MessageIterator(ptr, IntPtr.Zero);
479 } 464 }
480} 465}
@@ -529,20 +514,12 @@ public class MessageIterator
529 IntPtr new_iter = IntPtr.Zero; 514 IntPtr new_iter = IntPtr.Zero;
530 515
531 if (signature[0] == 'v') 516 if (signature[0] == 'v')
532 {
533 new_iter = eldbus_message_iter_container_new(Handle, 'v', signature.Substring(1)); 517 new_iter = eldbus_message_iter_container_new(Handle, 'v', signature.Substring(1));
534 }
535 else if (!eldbus_message_iter_arguments_append(Handle, signature, out new_iter)) 518 else if (!eldbus_message_iter_arguments_append(Handle, signature, out new_iter))
536 {
537 Eina.Error.RaiseIfOccurred();
538 throw new SEHException("Eldbus: could not append container type"); 519 throw new SEHException("Eldbus: could not append container type");
539 }
540 520
541 if (new_iter == IntPtr.Zero) 521 if (new_iter == IntPtr.Zero)
542 {
543 Eina.Error.RaiseIfOccurred();
544 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_arguments_append"); 522 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_arguments_append");
545 }
546 523
547 return new eldbus.MessageIterator(new_iter, Handle); 524 return new eldbus.MessageIterator(new_iter, Handle);
548 } 525 }
@@ -554,10 +531,7 @@ public class MessageIterator
554 IntPtr new_iter = eldbus_message_iter_container_new(Handle, type, contained_signature); 531 IntPtr new_iter = eldbus_message_iter_container_new(Handle, type, contained_signature);
555 532
556 if (new_iter == IntPtr.Zero) 533 if (new_iter == IntPtr.Zero)
557 {
558 Eina.Error.RaiseIfOccurred();
559 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_container_new"); 534 throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_container_new");
560 }
561 535
562 return new eldbus.MessageIterator(new_iter, Handle); 536 return new eldbus.MessageIterator(new_iter, Handle);
563 } 537 }
@@ -567,15 +541,10 @@ public class MessageIterator
567 CheckHandle(); 541 CheckHandle();
568 542
569 if (Parent == IntPtr.Zero) 543 if (Parent == IntPtr.Zero)
570 {
571 throw new SEHException("Eldbus: can not close MessageIterator open container without a parent"); 544 throw new SEHException("Eldbus: can not close MessageIterator open container without a parent");
572 }
573 545
574 if (!eldbus_message_iter_container_close(Parent, Handle)) 546 if (!eldbus_message_iter_container_close(Parent, Handle))
575 {
576 Eina.Error.RaiseIfOccurred();
577 throw new SEHException("Eldbus: could not close MessageIterator"); 547 throw new SEHException("Eldbus: could not close MessageIterator");
578 }
579 548
580 Handle = IntPtr.Zero; 549 Handle = IntPtr.Zero;
581 Parent = IntPtr.Zero; 550 Parent = IntPtr.Zero;
@@ -685,10 +654,7 @@ public class MessageIterator
685 IntPtr hdl = IntPtr.Zero; 654 IntPtr hdl = IntPtr.Zero;
686 bool r = eldbus_message_iter_get_and_next(Handle, typecode, out hdl); 655 bool r = eldbus_message_iter_get_and_next(Handle, typecode, out hdl);
687 if (hdl == IntPtr.Zero) 656 if (hdl == IntPtr.Zero)
688 {
689 Eina.Error.RaiseIfOccurred();
690 throw new SEHException("Eldbus: could not get argument"); 657 throw new SEHException("Eldbus: could not get argument");
691 }
692 iter = new eldbus.MessageIterator(hdl, Handle); 658 iter = new eldbus.MessageIterator(hdl, Handle);
693 659
694 return r; 660 return r;
@@ -699,10 +665,7 @@ public class MessageIterator
699 CheckHandle(); 665 CheckHandle();
700 IntPtr hdl = IntPtr.Zero; 666 IntPtr hdl = IntPtr.Zero;
701 if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero) 667 if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
702 {
703 Eina.Error.RaiseIfOccurred();
704 throw new SEHException("Eldbus: could not get argument"); 668 throw new SEHException("Eldbus: could not get argument");
705 }
706 iter = new eldbus.MessageIterator(hdl, Handle); 669 iter = new eldbus.MessageIterator(hdl, Handle);
707 670
708 return Next(); 671 return Next();
@@ -801,10 +764,7 @@ public class MessageIterator
801 CheckHandle(); 764 CheckHandle();
802 IntPtr hdl = IntPtr.Zero; 765 IntPtr hdl = IntPtr.Zero;
803 if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero) 766 if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
804 {
805 Eina.Error.RaiseIfOccurred();
806 throw new SEHException("Eldbus: could not get argument"); 767 throw new SEHException("Eldbus: could not get argument");
807 }
808 iter = new eldbus.MessageIterator(hdl, Handle); 768 iter = new eldbus.MessageIterator(hdl, Handle);
809 } 769 }
810 770
@@ -829,10 +789,7 @@ public class MessageIterator
829 CheckHandle(); 789 CheckHandle();
830 790
831 if (!eldbus_message_iter_fixed_array_get(Handle, type_code, out value, out n_elements)) 791 if (!eldbus_message_iter_fixed_array_get(Handle, type_code, out value, out n_elements))
832 {
833 Eina.Error.RaiseIfOccurred();
834 throw new SEHException("Eldbus: could not get fixed array"); 792 throw new SEHException("Eldbus: could not get fixed array");
835 }
836 } 793 }
837 794
838 public void GetFixedArray(out byte[] array) 795 public void GetFixedArray(out byte[] array)
diff --git a/src/bindings/mono/eldbus_mono/eldbus_object.cs b/src/bindings/mono/eldbus_mono/eldbus_object.cs
index 0dfe4d8..4488853 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_object.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_object.cs
@@ -121,10 +121,7 @@ public class Object : System.IDisposable
121 var handle = eldbus_object_get(conn.Handle, bus, path); 121 var handle = eldbus_object_get(conn.Handle, bus, path);
122 122
123 if (handle == IntPtr.Zero) 123 if (handle == IntPtr.Zero)
124 {
125 Eina.Error.RaiseIfOccurred();
126 throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get"); 124 throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get");
127 }
128 125
129 InitNew(handle, true); 126 InitNew(handle, true);
130 } 127 }
@@ -169,10 +166,7 @@ public class Object : System.IDisposable
169 var conn = eldbus_object_connection_get(Handle); 166 var conn = eldbus_object_connection_get(Handle);
170 167
171 if (conn == IntPtr.Zero) 168 if (conn == IntPtr.Zero)
172 {
173 Eina.Error.RaiseIfOccurred();
174 throw new SEHException("Eldbus: could not get `Connection' object from eldbus_object_connection_get"); 169 throw new SEHException("Eldbus: could not get `Connection' object from eldbus_object_connection_get");
175 }
176 170
177 return new eldbus.Connection(conn, false); 171 return new eldbus.Connection(conn, false);
178 } 172 }
@@ -216,10 +210,7 @@ public class Object : System.IDisposable
216 var pending_hdl = eldbus_object_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout); 210 var pending_hdl = eldbus_object_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
217 211
218 if (pending_hdl == IntPtr.Zero) 212 if (pending_hdl == IntPtr.Zero)
219 {
220 Eina.Error.RaiseIfOccurred();
221 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_send"); 213 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_send");
222 }
223 214
224 return new eldbus.Pending(pending_hdl, false); 215 return new eldbus.Pending(pending_hdl, false);
225 } 216 }
@@ -231,10 +222,7 @@ public class Object : System.IDisposable
231 var hdl = eldbus_object_method_call_new(Handle, _interface, member); 222 var hdl = eldbus_object_method_call_new(Handle, _interface, member);
232 223
233 if (hdl == IntPtr.Zero) 224 if (hdl == IntPtr.Zero)
234 {
235 Eina.Error.RaiseIfOccurred();
236 throw new SEHException("Eldbus: could not get `Message' object from eldbus_object_method_call_new"); 225 throw new SEHException("Eldbus: could not get `Message' object from eldbus_object_method_call_new");
237 }
238 226
239 return new eldbus.Message(hdl, false); 227 return new eldbus.Message(hdl, false);
240 } 228 }
@@ -249,10 +237,7 @@ public class Object : System.IDisposable
249 var pending_hdl = eldbus_object_peer_ping(Handle, cb_wrapper, cb_data); 237 var pending_hdl = eldbus_object_peer_ping(Handle, cb_wrapper, cb_data);
250 238
251 if (pending_hdl == IntPtr.Zero) 239 if (pending_hdl == IntPtr.Zero)
252 {
253 Eina.Error.RaiseIfOccurred();
254 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_ping"); 240 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_ping");
255 }
256 241
257 return new eldbus.Pending(pending_hdl, false); 242 return new eldbus.Pending(pending_hdl, false);
258 } 243 }
@@ -267,10 +252,7 @@ public class Object : System.IDisposable
267 var pending_hdl = eldbus_object_peer_machine_id_get(Handle, cb_wrapper, cb_data); 252 var pending_hdl = eldbus_object_peer_machine_id_get(Handle, cb_wrapper, cb_data);
268 253
269 if (pending_hdl == IntPtr.Zero) 254 if (pending_hdl == IntPtr.Zero)
270 {
271 Eina.Error.RaiseIfOccurred();
272 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_machine_id_get"); 255 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_machine_id_get");
273 }
274 256
275 return new eldbus.Pending(pending_hdl, false); 257 return new eldbus.Pending(pending_hdl, false);
276 } 258 }
@@ -285,10 +267,7 @@ public class Object : System.IDisposable
285 var pending_hdl = eldbus_object_introspect(Handle, cb_wrapper, cb_data); 267 var pending_hdl = eldbus_object_introspect(Handle, cb_wrapper, cb_data);
286 268
287 if (pending_hdl == IntPtr.Zero) 269 if (pending_hdl == IntPtr.Zero)
288 {
289 Eina.Error.RaiseIfOccurred();
290 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_introspect"); 270 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_introspect");
291 }
292 271
293 return new eldbus.Pending(pending_hdl, false); 272 return new eldbus.Pending(pending_hdl, false);
294 } 273 }
@@ -303,10 +282,7 @@ public class Object : System.IDisposable
303 var pending_hdl = eldbus_object_managed_objects_get(Handle, cb_wrapper, cb_data); 282 var pending_hdl = eldbus_object_managed_objects_get(Handle, cb_wrapper, cb_data);
304 283
305 if (pending_hdl == IntPtr.Zero) 284 if (pending_hdl == IntPtr.Zero)
306 {
307 Eina.Error.RaiseIfOccurred();
308 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_managed_objects_get"); 285 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_managed_objects_get");
309 }
310 286
311 return new eldbus.Pending(pending_hdl, false); 287 return new eldbus.Pending(pending_hdl, false);
312 } 288 }
diff --git a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
index 25903c9..fa34ce3 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs
@@ -133,10 +133,7 @@ public class Proxy : IDisposable
133 CheckHandle(); 133 CheckHandle();
134 var ptr = eldbus_proxy_object_get(Handle); 134 var ptr = eldbus_proxy_object_get(Handle);
135 if (ptr == IntPtr.Zero) 135 if (ptr == IntPtr.Zero)
136 {
137 Eina.Error.RaiseIfOccurred();
138 throw new SEHException("Eldbus: could not get `Object' object from eldbus_proxy_object_get"); 136 throw new SEHException("Eldbus: could not get `Object' object from eldbus_proxy_object_get");
139 }
140 return new eldbus.Object(ptr, false); 137 return new eldbus.Object(ptr, false);
141 } 138 }
142 139
@@ -156,10 +153,7 @@ public class Proxy : IDisposable
156 153
157 var ptr = eldbus_proxy_method_call_new(Handle, member); 154 var ptr = eldbus_proxy_method_call_new(Handle, member);
158 if (ptr == IntPtr.Zero) 155 if (ptr == IntPtr.Zero)
159 {
160 Eina.Error.RaiseIfOccurred();
161 throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_method_call_new"); 156 throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_method_call_new");
162 }
163 return new eldbus.Message(ptr, false); 157 return new eldbus.Message(ptr, false);
164 } 158 }
165 159
@@ -176,10 +170,7 @@ public class Proxy : IDisposable
176 var pending_hdl = eldbus_proxy_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout); 170 var pending_hdl = eldbus_proxy_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
177 171
178 if (pending_hdl == IntPtr.Zero) 172 if (pending_hdl == IntPtr.Zero)
179 {
180 Eina.Error.RaiseIfOccurred();
181 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send"); 173 throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send");
182 }
183 174
184 return new eldbus.Pending(pending_hdl, false); 175 return new eldbus.Pending(pending_hdl, false);
185 } 176 }
@@ -189,10 +180,7 @@ public class Proxy : IDisposable
189 CheckHandle(); 180 CheckHandle();
190 var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout); 181 var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout);
191 if (ptr == IntPtr.Zero) 182 if (ptr == IntPtr.Zero)
192 {
193 Eina.Error.RaiseIfOccurred();
194 throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block"); 183 throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block");
195 }
196 return new eldbus.Message(ptr, true); 184 return new eldbus.Message(ptr, true);
197 } 185 }
198 186
diff --git a/src/examples/eina/EinaError01.cs b/src/examples/eina/EinaError01.cs
index 0906271..8fceaef 100644
--- a/src/examples/eina/EinaError01.cs
+++ b/src/examples/eina/EinaError01.cs
@@ -37,7 +37,7 @@ public class ExampleEinaError01
37 try 37 try
38 { 38 {
39 testFunc(-1, "abc"); 39 testFunc(-1, "abc");
40 Eina.Error.RaiseIfOccurred(); 40 Eina.Error.RaiseIfUnhandledException();
41 } 41 }
42 catch(Efl.EflException e) 42 catch(Efl.EflException e)
43 { 43 {
@@ -58,7 +58,7 @@ public class ExampleEinaError01
58 { 58 {
59 testFunc(42, "abc"); 59 testFunc(42, "abc");
60 60
61 Eina.Error.RaiseIfOccurred(); 61 Eina.Error.RaiseIfUnhandledException();
62 62
63 err = Eina.Error.Get(); 63 err = Eina.Error.Get();
64 WriteLine($"Really no error? {err == Eina.Error.NO_ERROR}."); 64 WriteLine($"Really no error? {err == Eina.Error.NO_ERROR}.");
diff --git a/src/tests/efl_mono/Errors.cs b/src/tests/efl_mono/Errors.cs
index 9f4ebf2..36b1190 100644
--- a/src/tests/efl_mono/Errors.cs
+++ b/src/tests/efl_mono/Errors.cs
@@ -8,30 +8,15 @@ class TestEinaError
8 public static void basic_test() 8 public static void basic_test()
9 { 9 {
10 Eina.Error.Clear(); 10 Eina.Error.Clear();
11 Test.AssertNotRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred);
12 Eina.Error.Set(Eina.Error.ENOENT); 11 Eina.Error.Set(Eina.Error.ENOENT);
13 Test.AssertRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred); 12 Eina.Error err = Eina.Error.Get();
13 Test.AssertEquals(err, Eina.Error.ENOENT);
14 } 14 }
15} 15}
16 16
17class TestEolianError 17class TestEolianError
18{ 18{
19 19
20 public static void global_eina_error()
21 {
22 var obj = new Dummy.TestObject();
23 Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
24 }
25
26 class Child : Dummy.TestObject {
27 }
28
29 public static void global_eina_error_inherited()
30 {
31 var obj = new Child();
32 Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
33 }
34
35 class CustomException : Exception { 20 class CustomException : Exception {
36 public CustomException(string msg): base(msg) {} 21 public CustomException(string msg): base(msg) {}
37 } 22 }