File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed
packages/cubejs-api-gateway Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change
1
+ class UserError extends Error { }
2
+
3
+ module . exports = UserError ;
Original file line number Diff line number Diff line change 1
1
const chrono = require ( 'chrono-node' ) ;
2
2
const moment = require ( 'moment' ) ;
3
+ const UserError = require ( './UserError' ) ;
3
4
4
5
module . exports = ( dateString ) => {
5
6
let momentRange ;
@@ -28,6 +29,9 @@ module.exports = (dateString) => {
28
29
momentRange = [ yesterday , yesterday ] ;
29
30
} else {
30
31
const results = chrono . parse ( dateString ) ;
32
+ if ( ! results ) {
33
+ throw new UserError ( `Can't parse date: '${ dateString } '` ) ;
34
+ }
31
35
momentRange = results [ 0 ] . end ? [
32
36
results [ 0 ] . start . moment ( ) ,
33
37
results [ 0 ] . end . moment ( )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const Joi = require('joi');
4
4
const moment = require ( 'moment' ) ;
5
5
const dateParser = require ( './dateParser' ) ;
6
6
7
- class UserError extends Error { }
7
+ const UserError = require ( './UserError' ) ;
8
8
9
9
const toConfigMap = ( metaConfig ) => (
10
10
R . pipe (
You can’t perform that action at this time.
0 commit comments