Reputation: 100506
If I use new Error()
or new TypeError()
I am going to get something that looks like this for a stacktrace:
Error: Live-Mutex client lock request timed out after 6000ms
I am wondering if there is a way to generate a message that starts with "Warning:" instead of "Error:".
I don't think JS offers us new Warning()
but I am looking for something like that.
Ultimately, I am looking to pair it with process.emit('warning')
like so:
process.emit('warning', new Warning('foo bar baz'));
I need to have a stack trace available.
Upvotes: 1
Views: 195
Reputation: 1836
I believe you will be able to achieve your goal by using process.emitWarning.
Its first parameter can be either an Error object or simply a string containing your warning message. You may need to use the other parameters to tweak the result if it doesn't immediately meet the needs of your context.
Disclaimer: I have not used this function before. Let us know how it works out.
Upvotes: 1