File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,21 @@ const noCallback = require('../no-callback');
8
8
* @function
9
9
* @param {String } name name of job to schedule
10
10
* @param {Object } data data to pass to job
11
- * @returns {Job } new job instance created
11
+ * @returns {Promise } resolves with the new job instance created
12
12
*/
13
13
module . exports = async function ( name , data ) {
14
- // eslint-disable-next-line prefer-rest-params
15
- noCallback ( arguments , 2 ) ;
16
14
debug ( 'Agenda.now(%s, [Object])' , name ) ;
17
- const job = this . create ( name , data ) ;
15
+ try {
16
+ // eslint-disable-next-line prefer-rest-params
17
+ noCallback ( arguments , 2 ) ;
18
+ const job = this . create ( name , data ) ;
18
19
19
- job . schedule ( new Date ( ) ) ;
20
- await job . save ( ) ;
20
+ job . schedule ( new Date ( ) ) ;
21
+ await job . save ( ) ;
21
22
22
- return job ;
23
+ return job ;
24
+ } catch ( err ) {
25
+ debug ( 'error trying to create a job for this exact moment' ) ;
26
+ throw err ;
27
+ }
23
28
} ;
You can’t perform that action at this time.
0 commit comments