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
This commit is contained in:
parent
130fe0bf78
commit
e2589e3b48
|
@ -264,7 +264,7 @@ struct event_definition_generator
|
|||
<< scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n"
|
||||
<< scope_tab << scope_tab << "} catch (Exception e) {\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Error(e.ToString());\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
|
||||
<< scope_tab << scope_tab << "}\n"
|
||||
<< scope_tab << "}\n\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
|
|
|
@ -93,7 +93,7 @@ struct native_function_definition_generator
|
|||
<< "(" << (native_argument_invocation % ", ") << ");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
|
||||
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
|
||||
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "}\n"
|
||||
<< eolian_mono::native_function_definition_epilogue(*klass)
|
||||
<< scope_tab << scope_tab << "} else {\n"
|
||||
|
|
|
@ -99,7 +99,7 @@ struct function_definition_epilogue_generator
|
|||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
if (!as_generator(
|
||||
scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
|
||||
scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
|
||||
<< *(scope_tab << scope_tab << convert_out_assign)
|
||||
<< *(scope_tab << scope_tab << convert_in_ptr_assign)
|
||||
<< scope_tab << scope_tab << convert_return
|
||||
|
|
|
@ -90,7 +90,7 @@ struct function_pointer {
|
|||
<< scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
|
||||
<< scope_tab << scope_tab << "} catch (Exception e) {\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
|
||||
<< scope_tab << scope_tab << "}\n"
|
||||
<< native_function_definition_epilogue(nullptr)
|
||||
<< scope_tab << "}\n"
|
||||
|
|
|
@ -579,7 +579,7 @@ struct klass
|
|||
<< scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.data_set(this);\n"
|
||||
<< scope_tab << scope_tab << "}\n"
|
||||
<< scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_end(handle);\n"
|
||||
<< scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
|
||||
<< scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
|
||||
<< scope_tab << "}\n"
|
||||
|
||||
<< scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
|
||||
|
@ -718,7 +718,7 @@ struct klass
|
|||
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "}\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
|
||||
<< scope_tab << scope_tab << "} \n"
|
||||
<< scope_tab << scope_tab << "event_cb_count[key]++;\n"
|
||||
<< scope_tab << scope_tab << "return true;\n"
|
||||
|
@ -740,7 +740,7 @@ struct klass
|
|||
<< scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "}\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
|
||||
<< scope_tab << scope_tab << "} else if (event_count == 0) {\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n"
|
||||
<< scope_tab << scope_tab << scope_tab << "return false;\n"
|
||||
|
|
|
@ -14,7 +14,7 @@ public struct Error : IComparable<Error>
|
|||
get { return MsgGet(this); }
|
||||
}
|
||||
|
||||
public static Error EFL_ERROR;
|
||||
public static Error UNHANDLED_EXCEPTION;
|
||||
|
||||
public static Error NO_ERROR = new Error(0);
|
||||
public static Error EPERM = new Error(1);
|
||||
|
@ -41,7 +41,7 @@ public struct Error : IComparable<Error>
|
|||
|
||||
internal static void Init()
|
||||
{
|
||||
EFL_ERROR = eina_error_msg_register("Managed Code Error");
|
||||
UNHANDLED_EXCEPTION = eina_error_msg_register("Unhandled C# exception occurred.");
|
||||
}
|
||||
|
||||
[DllImport(efl.Libs.Eina)] static extern Error eina_error_msg_register(string msg);
|
||||
|
@ -65,11 +65,16 @@ public struct Error : IComparable<Error>
|
|||
return Eina.StringConversion.NativeUtf8ToManagedString(cstr);
|
||||
}
|
||||
|
||||
public static void RaiseIfOccurred()
|
||||
/// <summary>Raises an exception if an unhandled exception occurred before switching
|
||||
/// back to the native code. For example, in an event handler.</summary>
|
||||
public static void RaiseIfUnhandledException()
|
||||
{
|
||||
Error e = Get();
|
||||
Clear();
|
||||
Raise(e);
|
||||
if (e == UNHANDLED_EXCEPTION)
|
||||
{
|
||||
Clear();
|
||||
Raise(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Raise(Error e)
|
||||
|
|
|
@ -135,19 +135,13 @@ public abstract class BasicMessageArgument
|
|||
public void AppendTo(eldbus.Message msg)
|
||||
{
|
||||
if (!InternalAppendTo(msg))
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not append basic type to eldbus.Message");
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendTo(eldbus.MessageIterator iter)
|
||||
{
|
||||
if (!InternalAppendTo(iter))
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract char TypeCode {get;}
|
||||
|
|
|
@ -192,10 +192,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_connection_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_connection_send");
|
||||
}
|
||||
|
||||
msg.Ref();
|
||||
|
||||
|
@ -224,10 +221,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_name_request(Handle, bus, flags, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_request");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -245,10 +239,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_name_release(Handle, bus, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_release");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -266,10 +257,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_name_owner_get(Handle, bus, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_get");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -287,10 +275,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_name_owner_has(Handle, bus, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_has");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -305,10 +290,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_names_list(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_list");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -323,10 +305,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_names_activatable_list(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_activatable_list");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -341,10 +320,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_hello(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_hello");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -362,10 +338,7 @@ public class Connection : IDisposable
|
|||
var pending_hdl = eldbus_name_start(Handle, bus, flags, cb_wrapper, cb_data);
|
||||
|
||||
if(pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_start");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
|
|
@ -251,10 +251,7 @@ public class Message : IDisposable
|
|||
{
|
||||
var ptr = eldbus_message_method_call_new(dest, path, iface, method);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_call_new");
|
||||
}
|
||||
return new eldbus.Message(ptr, true);
|
||||
}
|
||||
|
||||
|
@ -262,10 +259,7 @@ public class Message : IDisposable
|
|||
{
|
||||
var ptr = eldbus_message_signal_new(path, _interface, name);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_signal_new");
|
||||
}
|
||||
return new eldbus.Message(ptr, true);
|
||||
}
|
||||
|
||||
|
@ -328,10 +322,7 @@ public class Message : IDisposable
|
|||
CheckHandle();
|
||||
var ptr = eldbus_message_error_new(Handle, error_name, error_msg);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_error_new");
|
||||
}
|
||||
return new eldbus.Message(ptr, false);
|
||||
}
|
||||
|
||||
|
@ -340,10 +331,7 @@ public class Message : IDisposable
|
|||
CheckHandle();
|
||||
var ptr = eldbus_message_method_return_new(Handle);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_return_new");
|
||||
}
|
||||
return new eldbus.Message(ptr, false);
|
||||
}
|
||||
|
||||
|
@ -471,10 +459,7 @@ public class Message : IDisposable
|
|||
CheckHandle();
|
||||
var ptr = eldbus_message_iter_get(Handle);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_get");
|
||||
}
|
||||
return new eldbus.MessageIterator(ptr, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
@ -529,20 +514,12 @@ public class MessageIterator
|
|||
IntPtr new_iter = IntPtr.Zero;
|
||||
|
||||
if (signature[0] == 'v')
|
||||
{
|
||||
new_iter = eldbus_message_iter_container_new(Handle, 'v', signature.Substring(1));
|
||||
}
|
||||
else if (!eldbus_message_iter_arguments_append(Handle, signature, out new_iter))
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not append container type");
|
||||
}
|
||||
|
||||
if (new_iter == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_arguments_append");
|
||||
}
|
||||
|
||||
return new eldbus.MessageIterator(new_iter, Handle);
|
||||
}
|
||||
|
@ -554,10 +531,7 @@ public class MessageIterator
|
|||
IntPtr new_iter = eldbus_message_iter_container_new(Handle, type, contained_signature);
|
||||
|
||||
if (new_iter == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_container_new");
|
||||
}
|
||||
|
||||
return new eldbus.MessageIterator(new_iter, Handle);
|
||||
}
|
||||
|
@ -567,15 +541,10 @@ public class MessageIterator
|
|||
CheckHandle();
|
||||
|
||||
if (Parent == IntPtr.Zero)
|
||||
{
|
||||
throw new SEHException("Eldbus: can not close MessageIterator open container without a parent");
|
||||
}
|
||||
|
||||
if (!eldbus_message_iter_container_close(Parent, Handle))
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not close MessageIterator");
|
||||
}
|
||||
|
||||
Handle = IntPtr.Zero;
|
||||
Parent = IntPtr.Zero;
|
||||
|
@ -685,10 +654,7 @@ public class MessageIterator
|
|||
IntPtr hdl = IntPtr.Zero;
|
||||
bool r = eldbus_message_iter_get_and_next(Handle, typecode, out hdl);
|
||||
if (hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get argument");
|
||||
}
|
||||
iter = new eldbus.MessageIterator(hdl, Handle);
|
||||
|
||||
return r;
|
||||
|
@ -699,10 +665,7 @@ public class MessageIterator
|
|||
CheckHandle();
|
||||
IntPtr hdl = IntPtr.Zero;
|
||||
if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get argument");
|
||||
}
|
||||
iter = new eldbus.MessageIterator(hdl, Handle);
|
||||
|
||||
return Next();
|
||||
|
@ -801,10 +764,7 @@ public class MessageIterator
|
|||
CheckHandle();
|
||||
IntPtr hdl = IntPtr.Zero;
|
||||
if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get argument");
|
||||
}
|
||||
iter = new eldbus.MessageIterator(hdl, Handle);
|
||||
}
|
||||
|
||||
|
@ -829,10 +789,7 @@ public class MessageIterator
|
|||
CheckHandle();
|
||||
|
||||
if (!eldbus_message_iter_fixed_array_get(Handle, type_code, out value, out n_elements))
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get fixed array");
|
||||
}
|
||||
}
|
||||
|
||||
public void GetFixedArray(out byte[] array)
|
||||
|
|
|
@ -121,10 +121,7 @@ public class Object : System.IDisposable
|
|||
var handle = eldbus_object_get(conn.Handle, bus, path);
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get");
|
||||
}
|
||||
|
||||
InitNew(handle, true);
|
||||
}
|
||||
|
@ -169,10 +166,7 @@ public class Object : System.IDisposable
|
|||
var conn = eldbus_object_connection_get(Handle);
|
||||
|
||||
if (conn == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Connection' object from eldbus_object_connection_get");
|
||||
}
|
||||
|
||||
return new eldbus.Connection(conn, false);
|
||||
}
|
||||
|
@ -216,10 +210,7 @@ public class Object : System.IDisposable
|
|||
var pending_hdl = eldbus_object_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_send");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -231,10 +222,7 @@ public class Object : System.IDisposable
|
|||
var hdl = eldbus_object_method_call_new(Handle, _interface, member);
|
||||
|
||||
if (hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_object_method_call_new");
|
||||
}
|
||||
|
||||
return new eldbus.Message(hdl, false);
|
||||
}
|
||||
|
@ -249,10 +237,7 @@ public class Object : System.IDisposable
|
|||
var pending_hdl = eldbus_object_peer_ping(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_ping");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -267,10 +252,7 @@ public class Object : System.IDisposable
|
|||
var pending_hdl = eldbus_object_peer_machine_id_get(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_machine_id_get");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -285,10 +267,7 @@ public class Object : System.IDisposable
|
|||
var pending_hdl = eldbus_object_introspect(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_introspect");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -303,10 +282,7 @@ public class Object : System.IDisposable
|
|||
var pending_hdl = eldbus_object_managed_objects_get(Handle, cb_wrapper, cb_data);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_managed_objects_get");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
|
|
@ -133,10 +133,7 @@ public class Proxy : IDisposable
|
|||
CheckHandle();
|
||||
var ptr = eldbus_proxy_object_get(Handle);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Object' object from eldbus_proxy_object_get");
|
||||
}
|
||||
return new eldbus.Object(ptr, false);
|
||||
}
|
||||
|
||||
|
@ -156,10 +153,7 @@ public class Proxy : IDisposable
|
|||
|
||||
var ptr = eldbus_proxy_method_call_new(Handle, member);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_method_call_new");
|
||||
}
|
||||
return new eldbus.Message(ptr, false);
|
||||
}
|
||||
|
||||
|
@ -176,10 +170,7 @@ public class Proxy : IDisposable
|
|||
var pending_hdl = eldbus_proxy_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);
|
||||
|
||||
if (pending_hdl == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send");
|
||||
}
|
||||
|
||||
return new eldbus.Pending(pending_hdl, false);
|
||||
}
|
||||
|
@ -189,10 +180,7 @@ public class Proxy : IDisposable
|
|||
CheckHandle();
|
||||
var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block");
|
||||
}
|
||||
return new eldbus.Message(ptr, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ExampleEinaError01
|
|||
try
|
||||
{
|
||||
testFunc(-1, "abc");
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
Eina.Error.RaiseIfUnhandledException();
|
||||
}
|
||||
catch(Efl.EflException e)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ public class ExampleEinaError01
|
|||
{
|
||||
testFunc(42, "abc");
|
||||
|
||||
Eina.Error.RaiseIfOccurred();
|
||||
Eina.Error.RaiseIfUnhandledException();
|
||||
|
||||
err = Eina.Error.Get();
|
||||
WriteLine($"Really no error? {err == Eina.Error.NO_ERROR}.");
|
||||
|
|
|
@ -8,30 +8,15 @@ class TestEinaError
|
|||
public static void basic_test()
|
||||
{
|
||||
Eina.Error.Clear();
|
||||
Test.AssertNotRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred);
|
||||
Eina.Error.Set(Eina.Error.ENOENT);
|
||||
Test.AssertRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred);
|
||||
Eina.Error err = Eina.Error.Get();
|
||||
Test.AssertEquals(err, Eina.Error.ENOENT);
|
||||
}
|
||||
}
|
||||
|
||||
class TestEolianError
|
||||
{
|
||||
|
||||
public static void global_eina_error()
|
||||
{
|
||||
var obj = new Dummy.TestObject();
|
||||
Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
|
||||
}
|
||||
|
||||
class Child : Dummy.TestObject {
|
||||
}
|
||||
|
||||
public static void global_eina_error_inherited()
|
||||
{
|
||||
var obj = new Child();
|
||||
Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
|
||||
}
|
||||
|
||||
class CustomException : Exception {
|
||||
public CustomException(string msg): base(msg) {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue