Skip to content

Commit c40c849

Browse files
committed
Add more verbose error messages to frame creation from json. closes kriskbx#56
1 parent aaffa30 commit c40c849

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/gtt-sync.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const program = require('commander');
44
const Config = require('./include/file-config');
55
const Cli = require('./include/cli');
66
const Tasks = require('./include/tasks');
7+
const Owner = require('./models/owner');
78

89
program
910
.option('-p --proxy <proxy>', 'use a proxy server with the given url')
@@ -16,10 +17,13 @@ Cli.verbose = program.verbose;
1617
let config = new Config(process.cwd())
1718
.set('proxy', program.proxy)
1819
.set('_checkToken', program.check_token),
19-
tasks = new Tasks(config);
20+
tasks = new Tasks(config),
21+
owner = new Owner(config);
2022

2123
tasks.syncInit()
2224
.then(() => tasks.sync.frames.length === 0 ? process.exit(0) : null)
25+
.then(() => owner.authorized())
26+
.catch(e => Cli.x(`Invalid access token!`, e))
2327
.then(() => {
2428
Cli.bar(`${Cli.fetch} Fetching or creating issues & merge requests...`, tasks.sync.frames.length);
2529
return tasks.syncResolve(Cli.advance);

src/models/frame.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class frame {
3434
frame._stop = json.stop;
3535
frame.notes = json.notes;
3636
frame.timezone = json.timezone;
37+
frame.validate();
3738

3839
return frame;
3940
}
@@ -56,6 +57,18 @@ class frame {
5657
return this;
5758
}
5859

60+
validate() {
61+
moment.suppressDeprecationWarnings = true;
62+
63+
if(!moment(this._start).isValid())
64+
throw `Error: Start date is not in a valid ISO date format!`;
65+
66+
if(!moment(this._stop).isValid())
67+
throw `Error: Stop date is not in a valid ISO date format!`;
68+
69+
moment.suppressDeprecationWarnings = false;
70+
}
71+
5972
_getCurrentDate() {
6073
if(this.timezone)
6174
return moment().tz(this.timezone).format();

src/models/frameCollection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class frameCollection extends Base {
1212
try {
1313
return Frame.fromFile(this.config, Fs.join(this.config.frameDir, file));
1414
} catch (e) {
15-
return false;
15+
console.log(e);
16+
throw `Error parsing frame file: ${file}`
1617
}
1718
})
1819
.filter(frame => frame);

0 commit comments

Comments
 (0)