-
Notifications
You must be signed in to change notification settings - Fork 125
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
Error stacktrace overhaul #1944
Changes from all commits
de7f19e
d174bda
ef3ab00
1f87f68
91b1c1e
54a8ee5
05ebb58
7071243
3fbb907
e0b1ba9
a2840fd
4a48ab2
d65f40b
9c564e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
|
||
declare global { | ||
namespace NodeJS { | ||
interface Global { | ||
kuzzle: any; | ||
NODE_ENV: string; | ||
} | ||
} | ||
} | ||
|
||
global.NODE_ENV = process.env.NODE_ENV; | ||
|
||
export {}; | ||
|
||
/* eslint-enable @typescript-eslint/no-namespace */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Kuzzle, a backend software, self-hostable and ready to use | ||
* to power modern apps | ||
* | ||
* Copyright 2015-2020 Kuzzle | ||
* mailto: support AT kuzzle.io | ||
* website: http://kuzzle.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Hilight user code | ||
* | ||
* e.g. | ||
* at BackendController._add (/home/kuzzle/lib/core/application/backend.ts:261:28) | ||
* at BackendController.register (/home/kuzzle/lib/core/application/backend.ts:187:10) | ||
* > at registerFoo (/home/aschen/projets/app/test.ts:12:18) | ||
* > at init (/home/aschen/projets/app/test.ts:8:3) | ||
* at Module._compile (internal/modules/cjs/loader.js:1133:30) | ||
*/ | ||
function hilightUserCode (line) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct me if I'm wrong but, rather than highlighting user code, this function filters out system code. #renaming #nitpicking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nop, it does not remove any line from the stacktrace |
||
// ignore first line (error message) or already enhanced | ||
if (! line.includes(' at ') || line.startsWith('>')) { | ||
return line; | ||
} | ||
|
||
if ( line.includes('kuzzle/lib/') // ignore kuzzle code | ||
|| (line.indexOf('at /') === -1 && line.charAt(line.indexOf('(') + 1) !== '/') // ignore node internal | ||
|| line.includes('node_modules') // ignore dependencies | ||
) { | ||
return ' ' + line; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we include the line if the comments say it is ignored? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it's an internal line from Node.js or from Kuzzle so we keep it either way because it's a bad pratice to hide stack calls (for us it's more difficult to debug Kuzzle bug, for users it can lead to confusion) |
||
} | ||
|
||
// hilight user code | ||
return '>' + line; | ||
} | ||
|
||
module.exports = { | ||
hilightUserCode, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe having a function to do this would be better instead of repeating this bit of code everywhere ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't because I use this method in a custom way in the
kerror/index.js
file