firebase-admin-java
firebase-admin-java copied to clipboard
Errors inside the SDK are not reported to the callback
In debugging #962, I found that the error was not passed back to the callback, which prevents proper debugging in deployment. In addition to logging the error, the error should have been passed to the callback.
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Root Cause:
- Errors were only logged inside the SDK but were not passed to the callback, preventing proper error handling and debugging. 2)This made it difficult for developers to catch exceptions and react accordingly.
Fix Implemented: Modified the SDK to ensure that errors are passed to the callback properly. Before Fix: Errors were only logged and never returned to the callback. Calling an SDK function that triggers an error. After Fix: Errors inside the SDK are now passed to the callback, not just logged.
Code to fix:
try { someAsyncOperation(new Callback() { @Override public void onSuccess(Result result) { callback.onSuccess(result); // Pass successful result }
@Override
public void onFailure(Exception e) {
log.error("Error occurred: " + e.getMessage(), e); // Log error
callback.onFailure(e); // Now forwarding error to callback
}
});
} catch (Exception e) { log.error("Unhandled exception: " + e.getMessage(), e); callback.onFailure(e); // Ensure callback receives error }