Fix unhandled exception while calling CoRegister
authorjay <woghd8754@naver.com>
Tue, 31 Aug 2021 12:56:30 +0000 (21:56 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 6 Sep 2021 09:09:37 +0000 (18:09 +0900)
src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs

index bff123d..dc90ce4 100755 (executable)
@@ -197,9 +197,18 @@ namespace Tizen.Nlp
             _msg.Connected += (sender, e) =>
             {
                 Log.Debug(LogTag, "start to register");
-                _msg.CoRegister(Application.Current.ApplicationInfo.ApplicationId, _noti);
-                _connectionState = ConnectedState.Connected;
-                tcs.SetResult(true);
+                try
+                {
+                    _msg.CoRegister(Application.Current.ApplicationInfo.ApplicationId, _noti);
+                    _connectionState = ConnectedState.Connected;
+                    tcs.SetResult(true);
+                }
+                catch (InvalidIOException)
+                {
+                    Log.Debug(LogTag, "Exception occurred while CoRegister");
+                    _connectionState = ConnectedState.Disconnected;
+                    tcs.SetException(new InvalidOperationException("invalid Port cause exception", new InvalidIOException()));
+                }
             };
             _msg.Rejected += (sender, e) =>
             {