-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Version info
Angular:
7.2.0
Firebase:
5.8.5
AngularFire:
5.1.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
node: v10.13.0
chrome: 73.0.3683.86
os: Windows 8.1
How to reproduce these conditions
Steps to set up and reproduce
export class Service{
constructor(private storage: AngularFireStorage) { }
getImageUrl(path: string): Observable<string> {
return this.storage.ref(path).getDownloadURL().pipe(
take(1),
catchError(() => of('/assets/default.png'))
)
);
}
export class Component{
constructor(private service: Service) { }
url: string;
getImageUrl(): {
this.service.getImageUrl(aPathFromSomeModel)
.subscribe(data => this.url = data, err => console.error(err));
}
Debug output
** Errors in the JavaScript console **
FirebaseStorageError {code_: "storage/invalid-root-operation", message_: "Firebase Storage: The operation 'getDownloadURL' c…eference using child, such as .child('file.png').", serverResponse_: null, name_: "FirebaseError"}
code: "storage/invalid-root-operation"
code_: "storage/invalid-root-operation"
message: "Firebase Storage: The operation 'getDownloadURL' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png')."
message_: "Firebase Storage: The operation 'getDownloadURL' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png')."
name: "FirebaseError"
name_: "FirebaseError"
serverResponse: null
serverResponse_: null
__proto__: Object
** Output from firebase.database().enableLogging(true); **
Expected behavior
When passing an empty, null or undefined path, the error should be handled by the catchError operator.
Actual behavior
The error is not handled by catchError and get passed through the error channel
Fix
I had to do a manual check before calling the getDownloadURL()
if (!path) {
return of('/assets/default.png');
}
I'm no sure if this is an actual issue or I'm just doing it wrong, so any tip would be appreciated.
Reactions are currently unavailable