question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error not being output within promise

See original GitHub issue

I have a scenario where I have a catch all for any error I cannot handle and it looks like so:

.catch(function(error){
                console.error(error);
                logger.error("Could not do something", {error: error});
                res.status(500).end();
            });

Now the problem I had originally was my console log would not output the error, it would just show an empty error object, however if I do console.error(error); it outputs the actual error, so there is an error there. So is there any reason why the error would not be output by winston but is by regular console.error.

If it helps the error is: [ReferenceError: repository is not defined]

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
indexzerocommented, Apr 19, 2018

This should be resolved in winston@3.0.0-rc4. Please consider upgrading. Thank you for using winston!

0reactions
tm1000commented, Nov 22, 2017

If anyone was curious into fixing this I was able to figure out how to echo out errors using Winston’s filters setting

filters:   [
	function (level, msg, meta) {
		return (!msg && typeof meta == 'object' && meta instanceof Error) ? meta.stack : msg
	}
]
[2017-11-22 12:55:26.050] [ERROR] console - Error: Error
    at Timeout._onTimeout (/usr/src/freepbx/zulu/node/test.js:6:11)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can I not throw inside a Promise.catch handler?
In your case, you are rejecting inside do1 by throwing an Error object. Now, the current promise will be in rejected state and...
Read more >
Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch() method of a Promise object schedules a function to be called when the promise is rejected. It immediately returns an equivalent ......
Read more >
Promise Error Handling - JavaScript Tutorial
In this tutorial, you will learn about promise error handling that shows you how to handle error in promises.
Read more >
Promises - Error Handling - Beginner JavaScript - Wes Bos
It means that there was an error in one of our promises, but we did not write any code in order to handle...
Read more >
JavaScript Promises – The promise.then, promise.catch and ...
A promise is an object in JavaScript that will produce a value sometime ... does not work so I catch the error so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found