Skip to content
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

Merged
merged 3 commits into from
Nov 8, 2023
Merged

Conversation

H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Nov 7, 2023

As the title states. Part of the effort to add some more useful logging to the commands.

@H-Shay H-Shay requested a review from a team as a code owner November 7, 2023 18:36
@@ -15,7 +15,6 @@ limitations under the License.
*/

import { ICommand } from "./ICommand";
import { MatrixClient } from "matrix-bot-sdk";
Copy link
Contributor Author

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.

Copy link
Contributor

@Half-Shot Half-Shot left a 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 :)

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()}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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 :)

src/commands/AttendanceCommand.ts Outdated Show resolved Hide resolved
@H-Shay H-Shay merged commit 4d8770b into main Nov 8, 2023
4 checks passed
@H-Shay H-Shay deleted the shay/attendance_logging branch November 8, 2023 22:55
@H-Shay
Copy link
Contributor Author

H-Shay commented Nov 8, 2023

Merged #195 into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants