-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log Server Errors #695
Log Server Errors #695
Conversation
Error responses now include all properties from the Error object. Such as `message` and `stack`.
This also exposes a lot of |
👍 * 💯 This will most definitely help us with debugging! While we are being clever, can we be more clever by doing below as well? with below code we can reduce https://github.com/campersau/ungit/blob/server_errors/source/git-api.js#L114-L120 to Object.defineProperty(Error.prototype, 'toString', {
value: function() {
return 'Message: ' + this.message + '\n' + this.stack;
}
}); |
@codingtwinky No, this somehow does not work. Maybe some Errors are overriding the default For example the
|
Sorry, it would have worked if the code was in a file which would be loaded everywhere. Looks like the tests mentioned do not require Should I move the |
Hmmm... I'm wondering if including in Would that be a better place? if not, I think |
also adding `Error.prototype.toString` override
I moved the code to |
👍 this is awesome! |
f0fd7e3
to
f3485a5
Compare
What happend here?
Looks like Node.js 0.10 does not like the |
it does not work in Node.js 0.10
I can reproduce this error in node/0.10.41. It seems like implementation of This seems to be fixed in later version and I guess I really shouldn't mess with existing core implementations.... :P > var n = 0;
undefined
> Object.defineProperty(Error.prototype, 'toString', {
... value: function() {
..... if (n++ > 5) return 'ugh oh';
..... return this.stack;
..... }
... });
[undefined]
> var e = new Error('abc')
ugh oh
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
[TL;DR;]
> e.stack
ugh oh
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:203:10)
at Interface._line (readline.js:532:8)
at Interface._ttyWrite (readline.js:761:14)
at ReadStream.onkeypress (readline.js:100:10)
at ReadStream.emit (events.js:98:17)
at emitKey (readline.js:1096:12)
> |
Some recent bugreports (#689, #679) contain client- and serverside logs but they do not contain any useful errors.
The main reasons for this are:
Error
s are not serializable withJSON.stringify
by defaultjsonResultOrFailProm
does not log anything in case of an errorThe first commit fixes point 1 by implementing
toJSON
onError
.Before an empty object
{}
would be returned now the response includes all fields of anError
object such asmessage
andstack
:So the errors are visible in the network panel:
The second commit logs the information provided by commit 1 in the client console.
The third commit logs errors in the server console and fixes point 2.