From 226bff3ed0772ff3b9d69ea45fb57f3c0c930029 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Sun, 25 Mar 2018 20:56:27 -0700 Subject: [PATCH] Android: include error types in getCurrentPosition error Summary: Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. Include geolocation error types in error, and provide feature parity with iOS. If error occurs when you call getCurrentPosition, then error object includes PERMISSION_DENIED, POSITION_UNAVAILABLE, TIMEOUT keys with error codes. It should be used to compare with error.code value. This is minor fix that provides feature parity with iOS. Closes https://github.com/facebook/react-native/pull/18533 Differential Revision: D7396586 Pulled By: mdvacca fbshipit-source-id: bd698b80a3d075456738a3d4e48b572ae819ee3d --- .../facebook/react/modules/location/PositionError.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/location/PositionError.java b/ReactAndroid/src/main/java/com/facebook/react/modules/location/PositionError.java index 82f7d0dc801..f8dffa5850a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/location/PositionError.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/location/PositionError.java @@ -35,9 +35,17 @@ public class PositionError { public static WritableMap buildError(int code, String message) { WritableMap error = Arguments.createMap(); error.putInt("code", code); + if (message != null) { error.putString("message", message); } + + /** + * Provide error types in error message. Feature parity with iOS + */ + error.putInt("PERMISSION_DENIED", PERMISSION_DENIED); + error.putInt("POSITION_UNAVAILABLE", POSITION_UNAVAILABLE); + error.putInt("TIMEOUT", TIMEOUT); return error; } }