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 warnings handler #1115

Merged
merged 2 commits into from
Oct 8, 2024
Merged

Add warnings handler #1115

merged 2 commits into from
Oct 8, 2024

Conversation

jaclarke
Copy link
Member

@jaclarke jaclarke commented Oct 7, 2024

See edgedb/edgedb#7822 for details.

@jaclarke jaclarke marked this pull request as ready for review October 8, 2024 11:43
@jaclarke jaclarke requested a review from scotttrinh October 8, 2024 11:43
Copy link
Collaborator

@scotttrinh scotttrinh left a comment

Choose a reason for hiding this comment

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

👑

@@ -1230,7 +1272,7 @@ export class BaseRawConnection {
(!inCodec && args !== null) ||
(this.stateCodec === INVALID_CODEC && state !== Session.defaults())
) {
[card, inCodec, outCodec] = await this._parse(
[card, inCodec, outCodec, _, _, _, warnings] = await this._parse(
Copy link
Collaborator

Choose a reason for hiding this comment

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

btw, I think these _ variable names are unnecessary? Maybe eslint would complain if you did this, but I think this is equivalent:

Suggested change
[card, inCodec, outCodec, _, _, _, warnings] = await this._parse(
[card, inCodec, outCodec,,,, warnings] = await this._parse(

Just a tiny nit, not even something I'm suggesting we do here, just putting it out there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh, I didn't know you could do that 🌈⭐. Though I think I prefer the underscores as it looks more intentional to me, and not that I've just typoed it.

const error_type = this.constructor as typeof EdgeDBError as any;
return Boolean(error_type.tags?.[tag]);
hasTag(tag: tags): boolean {
const error_type = this.constructor as typeof EdgeDBError;
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

let warnings: EdgeDBError[] | null = null;
client = client.withWarningHandler((_warnings) => (warnings = _warnings));

await expect(client.query("select _warn_on_call();")).resolves.toEqual([0]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is some kind of built-in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Sully 'documented' it here: edgedb/edgedb#7823. I think it only exists in test mode/dev mode though.

@jaclarke jaclarke merged commit 62d03d2 into master Oct 8, 2024
10 checks passed
@jaclarke jaclarke deleted the warnings branch October 8, 2024 21:02
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