Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it correct code?
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Title:
Is it correct code?
Miscellaneous
Thread ID:
01657875
Message ID:
01657875
Views:
42
Hi everybody,

We have a directive with the following code
 modal.result
            .then(function () {
                onRouteChangeOff();

                return self.onOk();
            })
            
            .catch(function (error) {
                self.logError(error);
                self.notifyError(error);
            })
            
            .then(function () {
                services.State.go(toState, toParams);
            })
It seems to me that this is written incorrectly. Why there is a catch block - should it be just the code without catch? E.g. if the modal returns OK, it should go inside first block?

Can you please translate the intention of this code to me? I see that if I answer 'Cancel' on the modal dialog, I'm inside the catch block with error undefined.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform