Created
June 10, 2018 17:08
-
-
Save saurabhpati/83ad684ff478091ccce338811505d865 to your computer and use it in GitHub Desktop.
A pragmatic suspiciousController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function suspiciousController($scope, $log, suspiciousService) { | |
var options = { | |
throwException: false // change to false in case no exception is to be thrown. | |
}; | |
$scope.doImportantStuff = function () { | |
try { | |
suspiciousService.doVeryImportantStuff(options) | |
.then(function (promisedData) { | |
// Do something with promised data. | |
$log.log('Doing something with promised data', promisedData); | |
}) | |
.catch(function (noCantDo) { | |
$log.log(noCantDo); | |
}); | |
} catch (error) { | |
$log.log(error); | |
// Submit this error to your api which logs this error using $http service. | |
} | |
} | |
} | |
suspiciousController.$inject = ['$scope', '$log', 'suspiciousService'] | |
angular | |
.module('demoModule') | |
.controller('suspiciousController', suspiciousController); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment