File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ @ngdoc error
2+ @name $q:norslvr
3+ @fullName No resolver function passed to $Q
4+ @description
5+
6+ Occurs when calling creating a promise using {@link $q} as a constructor, without providing the
7+ required `resolver` function.
8+
9+ ```
10+ //bad
11+ var promise = $q().then(doSomething);
12+
13+ //good
14+ var promise = $q(function(resolve, reject) {
15+ waitForSomethingAsync.then(resolve);
16+ }).then(doSomething);
17+ ```
Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ function $$QProvider() {
235235 * @returns {object } Promise manager.
236236 */
237237function qFactory ( nextTick , exceptionHandler ) {
238+ var $qMinErr = minErr ( '$q' ) ;
238239 function callOnce ( self , resolveFn , rejectFn ) {
239240 var called = false ;
240241 function wrap ( fn ) {
@@ -522,8 +523,7 @@ function qFactory(nextTick, exceptionHandler) {
522523
523524 var $Q = function Q ( resolver ) {
524525 if ( ! isFunction ( resolver ) ) {
525- // TODO(@caitp): minErr this
526- throw new TypeError ( 'Expected resolverFn' ) ;
526+ throw $qMinErr ( 'norslvr' , "Expected resolverFn, got '{0}'" , resolver ) ;
527527 }
528528
529529 if ( ! ( this instanceof Q ) ) {
You can’t perform that action at this time.
0 commit comments