covered daemon 500 code errors

This commit is contained in:
bill bittner 2017-06-02 22:19:47 -07:00
parent 610951fe99
commit bb5e67ade5
4 changed files with 13 additions and 15 deletions

View file

@ -46,8 +46,8 @@ function getClaimWithUri(uri, resolve, reject){
).then(function (getUriResponse) { ).then(function (getUriResponse) {
console.log(">> 'get claim' success..."); console.log(">> 'get claim' success...");
//check to make sure the daemon didn't just time out //check to make sure the daemon didn't just time out
if (getUriResponse.data.result.error === "Timeout"){ if (getUriResponse.data.result.error){
reject("get request to lbry daemon timed out"); reject(getUriResponse.data.result.error);
} }
console.log(">> response data:", getUriResponse.data); console.log(">> response data:", getUriResponse.data);
console.log(">> dl path =", getUriResponse.data.result.download_path) console.log(">> dl path =", getUriResponse.data.result.download_path)
@ -57,7 +57,7 @@ function getClaimWithUri(uri, resolve, reject){
*/ */
resolve(getUriResponse.data.result.download_path); resolve(getUriResponse.data.result.download_path);
}).catch(function(getUriError){ }).catch(function(getUriError){
console.log(">> 'get' error:", getUriError); console.log(">> 'get' error.");
// reject the promise with an error message // reject the promise with an error message
reject(getUriError); reject(getUriError);
return; return;

View file

@ -1,4 +1,4 @@
//var fs = require('fs'); var fs = require('fs');
var lbryApi = require('../helpers/lbryApi.js'); var lbryApi = require('../helpers/lbryApi.js');
function handlePublishError(error) { function handlePublishError(error) {
@ -26,10 +26,10 @@ function createPublishParams(name, filepath, license, nsfw) {
}; };
return publishParams; return publishParams;
} }
function deleteTemporaryFile(filepath, name){ function deleteTemporaryFile(filepath) {
fs.unlink(filepath, function(err) { fs.unlink(filepath, function(err) {
if (err) throw err; if (err) throw err;
console.log('successfully deleted ' + name); console.log('successfully deleted ' + filepath);
}); });
} }
@ -44,12 +44,12 @@ module.exports = {
.then(function(data){ .then(function(data){
console.log("publish promise success. Tx info:", data) console.log("publish promise success. Tx info:", data)
socket.emit("publish-complete", data); socket.emit("publish-complete", data);
deleteTemporaryFile(filepath, name); deleteTemporaryFile(filepath);
}) })
.catch(function(error){ .catch(function(error){
console.log("error:", error); console.log("error:", error);
socket.emit("publish-status", handlePublishError(error)); socket.emit("publish-status", handlePublishError(error));
deleteTemporaryFile(filepath, name); deleteTemporaryFile(filepath);
}); });
} }
} }

View file

@ -10,10 +10,10 @@ var queueApi = require('../helpers/queueApi.js');
function handleRequestError(error, res) { function handleRequestError(error, res) {
if ((error === "NO_CLAIMS") || (error === "NO_FREE_PUBLIC_CLAIMS")){ if ((error === "NO_CLAIMS") || (error === "NO_FREE_PUBLIC_CLAIMS")){
res.status(307).sendFile(path.join(__dirname, '../public', 'noClaims.html')); res.status(307).sendFile(path.join(__dirname, '../public', 'noClaims.html'));
} else if (error === "Invalid URI") { } else if (error.response.status === 500) {
res.status(400).sendFile(path.join(__dirname, '../public', 'invalidUri.html')); res.status(400).send(error.response.data.error.message);
} else { } else {
res.status(400).send(error); res.status(400).send(error.toString());
}; };
} }

View file

@ -1,10 +1,8 @@
module.exports = function(app) { module.exports = function(app) {
var http = require('http').Server(app); var http = require('http').Server(app);
var io = require('socket.io')(http); var io = require('socket.io')(http);
var fs = require('fs'); //var fs = require('fs');
var path = require('path'); var path = require('path');
var lbryApi = require('../helpers/lbryApi.js');
var queueApi = require('../helpers/queueApi.js');
var siofu = require("socketio-file-upload"); var siofu = require("socketio-file-upload");
var socketHelpers = require('../helpers/socketHelpers.js'); var socketHelpers = require('../helpers/socketHelpers.js');