Upload refactor #242
2 changed files with 14 additions and 13 deletions
|
@ -36,24 +36,18 @@ module.exports = {
|
||||||
handleRequestError: function (action, originalUrl, ip, error, res) {
|
handleRequestError: function (action, originalUrl, ip, error, res) {
|
||||||
logger.error(`Request Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
logger.error(`Request Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
||||||
postToStats(action, originalUrl, ip, null, null, error);
|
postToStats(action, originalUrl, ip, null, null, error);
|
||||||
const errorStatusAndMessage = this.returnErrorMessageAndStatus(error);
|
const [status, message] = this.returnErrorMessageAndStatus(error);
|
||||||
res
|
res
|
||||||
.status(errorStatusAndMessage[0])
|
.status(status)
|
||||||
.render('requestError', {
|
.render('requestError', this.createErrorResponsePayload(status, message));
|
||||||
status : errorStatusAndMessage[0],
|
|
||||||
message: errorStatusAndMessage[1],
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
handleApiError: function (action, originalUrl, ip, error, res) {
|
handleApiError: function (action, originalUrl, ip, error, res) {
|
||||||
logger.error(`Api ${action} Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
logger.error(`Api ${action} Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
||||||
postToStats(action, originalUrl, ip, null, null, error);
|
postToStats(action, originalUrl, ip, null, null, error);
|
||||||
const errorStatusAndMessage = this.returnErrorMessageAndStatus(error);
|
const [status, message] = this.returnErrorMessageAndStatus(error);
|
||||||
res
|
res
|
||||||
.status(errorStatusAndMessage[0])
|
.status(status)
|
||||||
.json({
|
.json(this.createErrorResponsePayload(status, message));
|
||||||
success: false,
|
|
||||||
message: errorStatusAndMessage[1],
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
useObjectPropertiesIfNoKeys: function (err) {
|
useObjectPropertiesIfNoKeys: function (err) {
|
||||||
if (Object.keys(err).length === 0) {
|
if (Object.keys(err).length === 0) {
|
||||||
|
@ -65,4 +59,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
},
|
},
|
||||||
|
createErrorResponsePayload (status, message) {
|
||||||
|
return {
|
||||||
|
status,
|
||||||
|
success: false,
|
||||||
|
message,
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -182,7 +182,7 @@ var publishFileFunctions = {
|
||||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
|||||||
this.updateUploadPercent('<p>Curious what magic is happening here? <a class="link--primary" target="blank" href="https://lbry.io/faq/what-is-lbry">Learn more.</a></p>');
|
this.updateUploadPercent('<p>Curious what magic is happening here? <a class="link--primary" target="blank" href="https://lbry.io/faq/what-is-lbry">Learn more.</a></p>');
|
||||||
},
|
},
|
||||||
showFilePublishFailure: function (msg){
|
showFilePublishFailure: function (msg){
|
||||||
this.updatePublishStatus('<p>Something went wrong...</p><p>' + msg + '</p><strong>For help, post the above error text in the #speech channel on the <a class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">lbry discord</a></strong>');
|
this.updatePublishStatus('<p>Something went wrong...</p><p><strong>' + msg + '</strong></p><p>For help, post the above error text in the #speech channel on the <a class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">lbry discord</a>');
|
||||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
|||||||
this.hidePublishProgressBar();
|
this.hidePublishProgressBar();
|
||||||
this.hideUploadPercent();
|
this.hideUploadPercent();
|
||||||
},
|
},
|
||||||
|
|
||||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
Loading…
Add table
Reference in a new issue
Presumably
const
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.