Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve error logging #344

Merged
merged 4 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/wise-falcons-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@capacitor-firebase/analytics": patch
"@capacitor-firebase/app": patch
"@capacitor-firebase/app-check": patch
"@capacitor-firebase/authentication": patch
"@capacitor-firebase/crashlytics": patch
"@capacitor-firebase/messaging": patch
"@capacitor-firebase/performance": patch
"@capacitor-firebase/remote-config": patch
---

fix: improve error logging
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
Expand Down Expand Up @@ -41,8 +42,9 @@ public void error(String message) {
}
}
);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -52,8 +54,9 @@ public void setUserId(PluginCall call) {
String userId = call.getString("userId", null);
implementation.setUserId(userId);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -68,8 +71,9 @@ public void setUserProperty(PluginCall call) {
String value = call.getString("value", null);
implementation.setUserProperty(key, value);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -80,8 +84,9 @@ public void setCurrentScreen(PluginCall call) {
String screenClassOverride = call.getString("screenClassOverride", null);
implementation.setCurrentScreen(screenName, screenClassOverride);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -96,8 +101,9 @@ public void logEvent(PluginCall call) {
JSObject params = call.getObject("params");
implementation.logEvent(name, params);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -107,8 +113,9 @@ public void setSessionTimeoutDuration(PluginCall call) {
Long duration = call.getLong("duration", 1800000L);
implementation.setSessionTimeoutDuration(duration);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -122,8 +129,9 @@ public void setEnabled(PluginCall call) {
}
implementation.setEnabled(enabled);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -137,8 +145,9 @@ public void resetAnalyticsData(PluginCall call) {
try {
implementation.resetAnalyticsData();
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}
}
4 changes: 0 additions & 4 deletions packages/analytics/ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@
"${BUILT_PRODUCTS_DIR}/Capacitor/Capacitor.framework",
"${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreInternal/FirebaseCoreInternal.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework",
"${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
Expand All @@ -267,10 +265,8 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreDiagnostics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreInternal.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.capawesome.capacitorjs.plugins.firebase.appcheck;

import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
Expand Down Expand Up @@ -35,8 +36,9 @@ public void error(String message) {
}
}
);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -47,8 +49,9 @@ public void initialize(PluginCall call) {
boolean isTokenAutoRefreshEnabled = call.getBoolean("isTokenAutoRefreshEnabled", false);
implementation.initialize(debug, isTokenAutoRefreshEnabled);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -62,8 +65,9 @@ public void setTokenAutoRefreshEnabled(PluginCall call) {
}
implementation.setTokenAutoRefreshEnabled(enabled);
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}
}
6 changes: 0 additions & 6 deletions packages/app-check/ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,19 @@
"${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseAppCheck/FirebaseAppCheck.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreInternal/FirebaseCoreInternal.framework",
"${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseAppCheck.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreDiagnostics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreInternal.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
2 changes: 2 additions & 0 deletions packages/app-check/ios/Plugin/FirebaseAppCheckPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Capacitor
*/
@objc(FirebaseAppCheckPlugin)
public class FirebaseAppCheckPlugin: CAPPlugin {
public let tag = "FirebaseApp"
public let errorEnabledMissing = "enabled must be provided."
public let errorGetTokenFailed = "Failed to get token."
private var implementation: FirebaseAppCheck?
Expand All @@ -19,6 +20,7 @@ public class FirebaseAppCheckPlugin: CAPPlugin {
let forceRefresh = call.getBool("forceRefresh") ?? false
implementation?.getToken(forceRefresh: forceRefresh, completion: { token, expireTimeMillis, error in
if let error = error {
CAPLog.print("[", self.tag, "] ", error)
call.reject(error.localizedDescription)
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.capawesome.capacitorjs.plugins.firebase.app;

import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
Expand All @@ -11,6 +12,7 @@
@CapacitorPlugin(name = "FirebaseApp")
public class FirebaseAppPlugin extends Plugin {

public static final String TAG = "FirebaseApp";
private FirebaseApp firebaseAppInstance;

public void load() {
Expand All @@ -23,8 +25,9 @@ public void getName(PluginCall call) {
JSObject ret = new JSObject();
ret.put("name", firebaseAppInstance.getName());
call.resolve(ret);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}

Expand All @@ -40,8 +43,9 @@ public void getOptions(PluginCall call) {
ret.put("projectId", options.getProjectId());
ret.put("storageBucket", options.getStorageBucket());
call.resolve(ret);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage());
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
}
}
}
4 changes: 0 additions & 4 deletions packages/app/ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,8 @@
"${BUILT_PRODUCTS_DIR}/Capacitor/Capacitor.framework",
"${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreInternal/FirebaseCoreInternal.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework",
"${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
Expand All @@ -281,10 +279,8 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreDiagnostics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreInternal.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
Expand Down
Loading