Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proper rejection
Message
 
 
À
Tous
Information générale
Forum:
AngularJS
Catégorie:
Codage, syntaxe et commandes
Titre:
Proper rejection
Divers
Thread ID:
01653655
Message ID:
01653655
Vues:
40
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform