Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper rejection
Message
 
 
To
All
General information
Forum:
AngularJS
Category:
Coding, syntax & commands
Title:
Proper rejection
Miscellaneous
Thread ID:
01653655
Message ID:
01653655
Views:
41
Hi everybody,

In our services we now have the following code
 var deferred = services.Deferred;

        services.Http.get("api/secRoles/" + id)
            .then(function (data) {
                deferred.resolve(data.data);
            })
            .catch(function (error, status) {
                deferred.reject(status);
            });

        return deferred.promise;
However, when I was testing the above I saw that the status was undefined while error contained the information including status. What is the correct way for the catch block and do we need it at all? What if I want to catch the error in the controller instead?

Also, related question. If I want to throw an error from the API controller and properly handle it in the controller.js code, what is the best Error Code to return back? We do have server error directive in every form that traps the 500 error and some others and handles them by displaying in a toastr. For my own exception I want to by-pass that handling.

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


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform