-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add more logging to attendance command #195
Conversation
@@ -15,7 +15,6 @@ limitations under the License. | |||
*/ | |||
|
|||
import { ICommand } from "./ICommand"; | |||
import { MatrixClient } from "matrix-bot-sdk"; |
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.
This is a drive-by cleanup - the import was unused.
8e1659f
to
8b8357e
Compare
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.
Looks good. I've suggested a way to keep the stacktraces :)
src/commands/AttendanceCommand.ts
Outdated
await append(inviteTargets, null, await spiRoom.getId(), spiRoom.roomId, null, doAppend); | ||
} | ||
catch (error) { | ||
throw new Error(`Error calculating invite acceptance in special interest room ${spiRoom}: ${error.toString()}`) |
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.
throw new Error(`Error calculating invite acceptance in special interest room ${spiRoom}: ${error.toString()}`) | |
throw new Error(`Error calculating invite acceptance in special interest room ${spiRoom}`, {cause: error }); |
Gives you a nice stacktrack
> new Error('Oh no, an error', { cause: new Error('caused by this cheeky thing')})
Error: Oh no, an error
at REPL2:1:1
at Script.runInThisContext (node:vm:121:12)
... 7 lines matching cause stack trace ...
at [_line] [as _line] (node:internal/readline/interface:887:18) {
[cause]: Error: caused by this cheeky thing
at REPL2:1:39
at Script.runInThisContext (node:vm:121:12)
at REPLServer.defaultEval (node:repl:593:29)
at bound (node:domain:432:15)
at REPLServer.runBound [as eval] (node:domain:443:12)
at REPLServer.onLine (node:repl:923:10)
at REPLServer.emit (node:events:526:35)
at REPLServer.emit (node:domain:488:12)
at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
at [_line] [as _line] (node:internal/readline/interface:887:18)
}
This feature is not used nearly enough https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#cause
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.
Cool thanks for the insight - I am new to typescript/javascript so appreciate the tips :)
Merged #195 into main. |
As the title states. Part of the effort to add some more useful logging to the commands.