Hey there! Currently, I'm developing an AngularJS application that utilizes a web API as the front end. In instances where a user lacks specific permissions, I handle this by returning an HttpResponseMessage containing a custom error message.
var message = string.Format("You do not have permission");
HttpError err = new HttpError(message);
return Request.CreateResponse(HttpStatusCode.NotFound, err);
Now, I am looking to display the above message in an alert using AngularJS, and here's what I've attempted so far:
$scope.Update = function () {
var servCall = ProjectSetting_Service.update(sub);
servCall.then(function (data) {
alert(JSON.stringify(data));
});
}, function (error) {
//How can I display the error message here?
}
If anyone could offer some guidance or assistance on how to achieve this, it would be greatly appreciated. Thank you!