I have the following method which is located within a service, this method in particular saves a user profile nothing to exciting.
// Save user Profile
saveProfile(user: User): Observable<Response> {
return Observable.fromPromise<Response>(
this.af.database.object('/users/' + user.userId).update({
first_name: user.first_name,
display_name: user.display_name,
biography: user.biography,
intent: user.intent,
seeking: user.seeking,
training: user.training,
dayDOB: user.dayDOB,
monthDOB: user.monthDOB,
yearDOB: user.yearDOB,
hobbies: user.hobbies,
last_name: user.last_name,
gender: user.gender,
address: user.Address
}).then((profile: any) => {
return new Response('Profile has been saved successfully', true);
})
.catch((err: any) => {
return new Response('Unable to save profile at this time, please try again later.', false);
}) as Promise<Response>
)
}
As you can see it returns a Promise of type Reponse this is my custom class which contains a string and a boolean I populate these values based on if the update was a success or not. I then refer the boolean value within my component to decide what to do next.
The issue I am experiencing is when I make this method fail it doesn't return what is specified within the catch section of the method, nor does it console.log any custom text I specify instead it just writes the following:
I have searched the firebase documentation but with no avail, has anyone experienced this before? did you managed to resolve it?
But seriously though why bother having a .catch if you can't catch these exceptions.
