summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-10-14 22:09:32 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-10-14 23:23:17 +0200
commitb670a1ab36fcf514751e4b356487a96088dbbd24 (patch)
tree8c9d2f01ee8e9a57a3a93555b70b84534623c736 /models
parent7d57ce896baeac74498e8b76b5812ceb6df8b950 (diff)
downloadwekan-b670a1ab36fcf514751e4b356487a96088dbbd24.tar.gz
wekan-b670a1ab36fcf514751e4b356487a96088dbbd24.tar.bz2
wekan-b670a1ab36fcf514751e4b356487a96088dbbd24.zip
Import single card: proper error handling
Diffstat (limited to 'models')
-rw-r--r--models/import.js48
1 files changed, 26 insertions, 22 deletions
diff --git a/models/import.js b/models/import.js
index a76bbc5f..51206ea3 100644
--- a/models/import.js
+++ b/models/import.js
@@ -1,40 +1,44 @@
Meteor.methods({
- /**
- *
- */
importTrelloCard(trelloCard, listId, sortIndex) {
// 1. check parameters are ok from a syntax point of view
DateString = Match.Where(function (dateAsString) {
check(dateAsString, String);
return moment(dateAsString, moment.ISO_8601).isValid();
});
- check(trelloCard, Match.ObjectIncluding({
- name: String,
- desc: String,
- closed: Boolean,
- dateLastActivity: DateString,
- labels: [Match.ObjectIncluding({
+ try {
+ check(trelloCard, Match.ObjectIncluding({
name: String,
- color: String,
- })],
- actions: [Match.ObjectIncluding({
- type: String,
- date: DateString,
- data: Object,
- })],
- members: [Object],
- }));
- check(listId, String);
- check(sortIndex, Number);
+ desc: String,
+ closed: Boolean,
+ dateLastActivity: DateString,
+ labels: [Match.ObjectIncluding({
+ name: String,
+ color: String,
+ })],
+ actions: [Match.ObjectIncluding({
+ type: String,
+ date: DateString,
+ data: Object,
+ })],
+ members: [Object],
+ }));
+ check(listId, String);
+ check(sortIndex, Number);
+ } catch(e) {
+ if(Meteor.isServer) {
+ console.log(e);
+ }
+ throw new Meteor.Error('error-json-schema');
+ }
// 2. check parameters are ok from a business point of view (exist & authorized)
const list = Lists.findOne(listId);
if(!list) {
- throw 'exception-list-doesNotExist';
+ throw new Meteor.Error('error-list-doesNotExist');
}
if(Meteor.isServer) {
if (!allowIsBoardMember(Meteor.userId(), Boards.findOne(list.boardId))) {
- throw 'exception-board-notAMember';
+ throw new Meteor.Error('error-board-notAMember');
}
}