capacitor-community / date-picker

Native DateTime Picker Plugin for Capacitor Apps
MIT License
87 stars 29 forks source link

App crashes if date input does not match picker format #13

Closed roxteddy closed 4 years ago

roxteddy commented 4 years ago

Describe the bug App crashes instead of returning an error

To Reproduce Steps to reproduce the behavior: 1a - open date picker with custom date (ex: "2020-07-22") 1b - open date picker with ISOstring + offset (ex: "2020-07-22T00:00:00+02:00") (choose a or b - we don't set picker format so it expects an ISO string)

2 - CRASH

Expected behavior handle error locally and return a reason in Promise error

Smartphone (please complete the following information):

iOS Logs

⚡️ [log] - from: 2020-07-22T00:00:00+02:00 ⚡️ To Native -> DatePickerPlugin present 109690302 Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/maxime/work/platform/frontend/apps/mobile/node_modules/@capacitor-community/date-picker/ios/Plugin/Plugin.swift, line 149 2020-08-21 12:32:01.539110+0200 App[415:45250] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/maxime/work/platform/frontend/apps/mobile/node_modules/@capacitor-community/date-picker/ios/Plugin/Plugin.swift, line 149 (lldb)

⚡️ [log] - from: 2020-07-22 ⚡️ To Native -> DatePickerPlugin present 130320960 Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/maxime/work/platform/frontend/apps/mobile/node_modules/@capacitor-community/date-picker/ios/Plugin/Plugin.swift, line 149 2020-08-21 12:49:26.596721+0200 App[427:48517] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/maxime/work/platform/frontend/apps/mobile/node_modules/@capacitor-community/date-picker/ios/Plugin/Plugin.swift, line 149

Android Logs 2020-08-21 15:12:52.886 19389-19557/com.agorapulse.beta.app V/Capacitor: callback: 71300384, pluginId: DatePickerPlugin, methodName: present, methodData: {"theme":"light","date":"2020-07-22T00:00:00+02:00","mode":"date","max":"2020-08-20T15:12:52+02:00"} 2020-08-21 15:12:52.890 19389-19503/com.agorapulse.beta.app E/Capacitor: Serious error executing plugin java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$1.run(Bridge.java:521) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.text.ParseException: Unparseable date: "2020-07-22T00:00:00+02:00" at java.text.DateFormat.parse(DateFormat.java:362) at com.getcapacitor.community.datepicker.DatePickerPlugin.parseDateFromString(DatePickerPlugin.java:121) at com.getcapacitor.community.datepicker.DatePickerPlugin.launchDate(DatePickerPlugin.java:210) at com.getcapacitor.community.datepicker.DatePickerPlugin.present(DatePickerPlugin.java:279) at java.lang.reflect.Method.invoke(Native Method)  at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)  at com.getcapacitor.Bridge$1.run(Bridge.java:521)  at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at android.os.Looper.loop(Looper.java:214)  at android.os.HandlerThread.run(HandlerThread.java:67)  2020-08-21 15:12:52.891 19389-19503/com.agorapulse.beta.app E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins Process: com.agorapulse.beta.app, PID: 19389 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.getcapacitor.Bridge$1.run(Bridge.java:530) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$1.run(Bridge.java:521) at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at android.os.Looper.loop(Looper.java:214)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.text.ParseException: Unparseable date: "2020-07-22T00:00:00+02:00" at java.text.DateFormat.parse(DateFormat.java:362) at com.getcapacitor.community.datepicker.DatePickerPlugin.parseDateFromString(DatePickerPlugin.java:121) at com.getcapacitor.community.datepicker.DatePickerPlugin.launchDate(DatePickerPlugin.java:210) at com.getcapacitor.community.datepicker.DatePickerPlugin.present(DatePickerPlugin.java:279) at java.lang.reflect.Method.invoke(Native Method)  at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)  at com.getcapacitor.Bridge$1.run(Bridge.java:521)  at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at android.os.Looper.loop(Looper.java:214)  at android.os.HandlerThread.run(HandlerThread.java:67)