[NUI] Add try-catch block in New function (#2119)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 3 Nov 2020 01:16:33 +0000 (10:16 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 4 Nov 2020 01:03:52 +0000 (10:03 +0900)
- VD Kona : DF200922-00146
- Anlayze the log when the problem is reproduced,
 after inserting the try-catch block with log.

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
Co-authored-by: dongsug-song <35130733+dongsug-song@users.noreply.github.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs

index accce45..257dba8 100755 (executable)
@@ -18,6 +18,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
+using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading.Tasks;
@@ -1256,11 +1257,23 @@ namespace Tizen.NUI
 
         public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
         {
-            int argc = args.Length;
-            string argvStr = string.Join(" ", args);
-
-            Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
+            Application ret = null;
+            int argc = 0;
+            string argvStr = "";
+            try
+            {
+                argc = args.Length;
+                argvStr = string.Join(" ", args);
+            }
+            catch (Exception exception)
+            {
+                Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
+                Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
+                Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
+                throw;
+            }
 
+            ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             return ret;
@@ -1275,11 +1288,25 @@ namespace Tizen.NUI
 
         public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
         {
-            int argc = args.Length;
-            string argvStr = string.Join(" ", args);
+            Application ret = null;
+            int argc = 0;
+            string argvStr = "";
+            try
+            {
+                argc = args.Length;
+                argvStr = string.Join(" ", args);
+            }
+            catch (Exception exception)
+            {
+                Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
+                Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
+                Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
+                throw;
+            }
 
-            Application ret = new Application(NDalicPINVOKE.Application_New_WithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
+            ret = new Application(NDalicPINVOKE.Application_New_WithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
             return ret;
         }
 
index 9d6a315..c104c1a 100755 (executable)
@@ -193,6 +193,10 @@ namespace Tizen.NUI
                         }
                     }
                 }
+                if (e == null)
+                {
+                    e = new global::System.ApplicationException($"FATAL: Exception e is null, numExceptionsPending : {numExceptionsPending}");
+                }
                 return e;
             }
         }