Skip to content

Commit

Permalink
Extra error handling added
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Apr 7, 2017
1 parent 1f117ce commit ba9dffd
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 41 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -4,4 +4,6 @@ src/**/*.js
*.tgz
tests/local-test.js
tests/download-test.js
tests/downloads
tests/downloads
yarn.lock
.vscode
64 changes: 32 additions & 32 deletions README.md
Expand Up @@ -112,46 +112,46 @@ With the files_metadata option you can specify the metadata of all the files you
{
"name": "Item_Minimal.js",
"metadata": {
"__metadata": {
"type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
},
"Title": "Item Minimal Template (via GULP)",
"MasterPageDescription": "This is a display template added via gulp.",
"ManagedPropertyMapping": "'Path','Title':'Title'",
"ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
"DisplayTemplateLevel": "Item",
"TemplateHidden": false,
"TargetControlType": {
"__metadata": {
"type": "Collection(Edm.String)"
"type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
},
"results": [
"SearchResults",
"Content Web Parts"
]
}
"Title": "Item Minimal Template (via GULP)",
"MasterPageDescription": "This is a display template added via gulp.",
"ManagedPropertyMapping": "'Path','Title':'Title'",
"ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
"DisplayTemplateLevel": "Item",
"TemplateHidden": false,
"TargetControlType": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results": [
"SearchResults",
"Content Web Parts"
]
}
}
},
{
"name": "Control_Minimal.js",
"metadata": {
"__metadata": {
"type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
},
"Title": "Control Minimal Template (via GULP)",
"MasterPageDescription": "This is a display template added via gulp.",
"ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
"DisplayTemplateLevel": "Control",
"TemplateHidden": false,
"TargetControlType": {
"metadata": {
"__metadata": {
"type": "Collection(Edm.String)"
"type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
},
"results": [
"SearchResults",
"Content Web Parts"
]
}
"Title": "Control Minimal Template (via GULP)",
"MasterPageDescription": "This is a display template added via gulp.",
"ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
"DisplayTemplateLevel": "Control",
"TemplateHidden": false,
"TargetControlType": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results": [
"SearchResults",
"Content Web Parts"
]
}
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "gulp-spsync-creds",
"version": "2.3.1",
"version": "2.3.2",
"description": "Gulp plugin that syncs with a library in SharePoint Online and on-premises",
"main": "./release/index.js",
"scripts": {
Expand Down
9 changes: 6 additions & 3 deletions release/helpers/downloadFiles.js
Expand Up @@ -18,6 +18,8 @@ var FileDownload = (function () {
return new Promise(function (resolve, reject) {
_this.start().then(function (results) {
resolve(results);
}).catch(function (err) {
reject(err);
});
});
};
Expand Down Expand Up @@ -77,6 +79,8 @@ var FileDownload = (function () {
else {
resolve(null);
}
}).catch(function (err) {
reject(err);
});
});
};
Expand Down Expand Up @@ -133,9 +137,8 @@ var FileDownload = (function () {
_this.spr.get(_this.config.site + "/_api/web/GetFolderByServerRelativeUrl('" + _this.config.startFolder + "')?$expand=" + expand, headers)
.then(function (data) {
resolve(data);
})
.catch(function (err) {
resolve(null);
}).catch(function (err) {
reject(err);
});
});
};
Expand Down
7 changes: 7 additions & 0 deletions release/index.js
Expand Up @@ -72,6 +72,13 @@ function download(args) {
stream.end();
});
}
}).catch(function (err) {
if (typeof err.message !== "undefined") {
gutil.log(gutil.colors.red("ERROR: " + err.message));
}
else {
gutil.log(gutil.colors.red("ERROR: " + JSON.stringify(err)));
}
});
}
else {
Expand Down
9 changes: 6 additions & 3 deletions src/helpers/downloadFiles.ts
Expand Up @@ -29,6 +29,8 @@ export class FileDownload {
return new Promise<any>((resolve, reject) => {
this.start().then(results => {
resolve(results);
}).catch(err => {
reject(err);
});
});
}
Expand Down Expand Up @@ -87,6 +89,8 @@ export class FileDownload {
} else {
resolve(null);
}
}).catch(err => {
reject(err);
});
});
}
Expand Down Expand Up @@ -150,9 +154,8 @@ export class FileDownload {
)
.then(data => {
resolve(data);
})
.catch(err => {
resolve(null);
}).catch(err => {
reject(err);
});
});
};
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Expand Up @@ -87,7 +87,13 @@ export function download (args: ISettings) {
stream.end();
});
}
});
}).catch(err => {
if (typeof err.message !== "undefined") {
gutil.log(gutil.colors.red(`ERROR: ${err.message}`));
} else {
gutil.log(gutil.colors.red(`ERROR: ${JSON.stringify(err)}`));
}
});
} else {
gutil.log(gutil.colors.red("Please specify the startFolder"));
// End the steam
Expand Down

0 comments on commit ba9dffd

Please sign in to comment.