Does anybody know how to print more details about unexpected error that occurred?
I have this piece of code:
process.on('uncaughtException', function(err)
{
console.log("Unexpected error occurred. " + err + ".");
process.exit(1);
});
...and when error occurs this is printed: "Unexpected error occurred. Error: connect ECONNREFUSED."
There is no details about this error. Like what exactly failed, which connection, ip:port. How can I fetch that kind of data? And I don't want to use Domain module (in case somebody suggests).
Related
I am using Sails and Mysql to handle the database of my app. I recently clicked on a chrome autofill URL that took me to a 404'd page, since that url localhost:1337/companies was not active in this project.
Ever since I did that, my app returns
error: Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
and
Details: Error: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
any time I go to a url in my app. I tried cloning my app and relinking the database to no avail. I see this is a common issue people run into with sails, but none of the mentioned solutions were able to fix it for me.
Everything was working before I clicked that URL which makes me believe it may be a route issue, but the app still works, it will just fill up my terminal with the above errors.
Any help is greatly appreciated!
Edit: this is the custom API call I was working on in my controller.js when I started seeing the error:
winner: function (req, res) {
User.findOne({id: req.param('id')}).exec(function(err, user) {
if (err) {
return res.negotiate(err);
}
else {
var u = user;
u.totalwins++;
u.save();
sails.io.sockets.emit("chat", {verb:"score", data:{id: req.param('id'), name: user.name}});
}
});
}
Also receiving this error in my chrome-browser console:
:1337/user/quizzes Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I don't know if I am doing something incorrect here or what, but I have a question regarding error handling in angular.
I've gone through several similar questions on the website but they don't answer my question or solve my problem.
So this is basically what I'm trying to do:
var deferObject = $q.defer();
$http(some_url + user_entered_value).then(function(response){
deferObject.resolve(response.data);
}, function(error){
//error handling code here
deferObject.reject(error.data);
});
The server returns an error object which looks like this: {"status":"500","error":"Internal Server Error"}
Whenever there is an error in the application, angular throws an error by logging it in the console: "failed to load resource: Internal server error".
So here are my questions:
How do I prevent the angular error logging?
How do I handle that error?
I tried doing this:
var deferObject = $q.defer();
$http(some_url + user_entered_value).then(function(response){
deferObject.resolve(response.data);
}, function(error){
//error handling code here
deferObject.reject(error.data);
}).catch(function(e){
throw e;//to handle the error
});
But I still get the error in the console.
I have triggering an Ajax call and in the error callback I am trying to access the exception message(Not the Response Text). I am throwing an exception like this:
throw new Exception("Please enter a response")
Now I want to get the above message and display it in alert box.
I searched stackoverflow and found this:
error: function(e,status){
var err = eval("(" + e.responseText + ")");
alert(err.Message);
}
but the above doesn't work.
I am getting the response text but not able to access that particular message.
The error that I am getting is Uncaught SyntaxError: Unexpected token <
When your server throws an Internal Server Error, from Javascript side it's still a succes. how about adding the Status code response instead of throwing exception from the backend
return new HttpStatusCodeResult(400, "Custom Error Message 2");
You can refer this and try to get error message as alert(err.message); (lowercase) not alert(err.Message);
I'm currenlty working on a TS3 query bot written in node.js.
I added an auto reconnect to it but I have the issue now that the bot crashes if the server is offline with the following error:
events.js:85
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)
The line which starts the connection is the following:
var cl = new ts3.TeamSpeakClient(config.serverIP);
used with the node-ts api -> https://github.com/nikeee/node-ts
I already added the following events:
cl.on('error', function(err){
console.log("bla: " + err)
});
cl.on('uncaughtException', function (err) {
console.log(err);
});
uncaughtException doesn't get triggered and error doesn't prevent the crash.
How can I prevent it from crashing?
Edit: It's async btw.
You need to catch the UncaughtException on the process rather than in ts3 object.
process.on('uncaughtException', function (err) {
console.log(err);
})
More on handling exceptions can be found over here.
UPDATE:
cl has its own fail promise as well. To be implemented like this:
cl.fail(function(err) {
console.log("An error occurred." + util.inspect(err))
});
Im getting this error:
Error: Command failed: execvp(): Permission denied
When I do a simple node-imagemagick script:
im = require('imagemagick');
im.identify.path = '/tmp/node_thumbs/';
im.identify('cool.jpg',function(err,features){
if(err) throw err;
console.log(features);
});
Any ideas on what could be causing this?
The permission denied is from trying to launch the ImageMagick command, not in the process of executing it.
If you look at the documentation, identify.path is "Path to the identify program." In this case, you're redefining the path to the executable as /tmp/node_thumbs/, which presumably is not the executable.
You probably simply want:
var im = require("imagemagick");
im.identify('/tmp/node_thumbs/cool.jpg',function...