While calling a service, it calls API using $http method. In the same service I want to add conditional statement which is responsible to return another success or failure object without calling any API/URL. Something like this:
call someMethod()
{
if (statement true) { return httpResponseObject; }
else { return responseObject; }
}
The else part I need to return object responseObject in such a way so it can invoke the error block of method which is calling someMethod() as a service.
I tried return false;, return -1;, its not working. Also, I tried using ResponseText of XMLHttpRequest but didn't work.
Any help, how to create a HTTPResponse object which can be used in same way just as it would be returned by $Http response object. Something like attached snapshot:

$q.resolveto return a successful promise. Use$q.rejectto return a promise that is resolved as rejected. For more information, see AngularJS $q Service API Reference