fix: Refactor error logic to remove PrefixedFirebaseError as a intermediate class#3159
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the error handling system by removing the PrefixedFirebaseError class and integrating its functionality directly into the base FirebaseError class. It introduces a new hasCode method to FirebaseError to allow checking error codes without explicit knowledge of service prefixes. Additionally, it defines new error code constants and types for the Database, Firestore, and Storage services. Feedback was provided regarding the hasCode implementation, noting that it should check against the full error code before attempting a prefixed match to ensure consistent behavior and support polymorphism.
egilmorez
left a comment
There was a problem hiding this comment.
Thanks for the offline clarifications Jonathan! LGTM
This PR:
PrefixedFirebaseErrorto directly extend service error classes from the exposedFirebaseErrorhasCode()helper function toFirebaseErrorand encapsulate prefix logic in the service error classesFirebaseErrorbeing used with a manual service error prefix.This PR also creates specific error classes for Database, Firestore, Storage, and Machine Learning, replacing legacy instances where generic
FirebaseErrorobjects were thrown with hardcoded string prefixes.