diff --git a/src/YaNco.Core/Connection.cs b/src/YaNco.Core/Connection.cs index 21c1da67..33cb8e40 100644 --- a/src/YaNco.Core/Connection.cs +++ b/src/YaNco.Core/Connection.cs @@ -82,9 +82,13 @@ public Connection( catch (Exception ex) { rfcRuntime.Logger.IfSome(l => l.LogException(ex)); + return (null, Prelude.Left(RfcErrorInfo.Error(ex.Message))); } - throw new InvalidOperationException(); + rfcRuntime.Logger.IfSome(l => l.LogError( + $"Invalid rfc connection message {msg.GetType()}")); + return (null, Prelude.Left(RfcErrorInfo.Error($"Invalid rfc connection message {msg.GetType().Name}"))); + }); } diff --git a/src/YaNco.Core/RfcServer.cs b/src/YaNco.Core/RfcServer.cs index 011b035c..e12bf2a9 100644 --- a/src/YaNco.Core/RfcServer.cs +++ b/src/YaNco.Core/RfcServer.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using Dbosoft.Functional; using LanguageExt; @@ -75,9 +74,13 @@ private RfcServer(IRfcServerHandle serverHandle, IRfcRuntime rfcRuntime) catch (Exception ex) { rfcRuntime.Logger.IfSome(l => l.LogException(ex)); + return (null, Prelude.Left(RfcErrorInfo.Error(ex.Message))); } - throw new InvalidOperationException(); + rfcRuntime.Logger.IfSome(l => l.LogError( + $"Invalid rfc server message {msg.GetType()}")); + return (null, Prelude.Left(RfcErrorInfo.Error($"Invalid rfc server message {msg.GetType().Name}"))); + }); }