Purposefully Invoke an Error in $http Post Request
<p>I'm using Angular to send a post request with the <code>$http</code> service. I am doing all of the data validation of the form in Angular prior to sending the post request. However, there is one validation I am doing in PHP of whether the user already exists in the database. How do I purposefully invoke an error (<strong>in the php file</strong>) so that the Angular error callback is triggered instead of the success callback? Should I purposefully throw an exception?</p>

<p>IF the intent is to throw an exception, does the exception message get passed into the <code>data</code> parameter for the Angular <code>error</code> callback function?</p>