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

Register the on_error handler #1002

Merged
merged 1 commit into from
Jan 18, 2025
Merged

Register the on_error handler #1002

merged 1 commit into from
Jan 18, 2025

Conversation

markbackman
Copy link
Contributor

Please describe the changes in your PR. If it is addressing an issue, please reference that as well.

This PR went stale: #568. I'm doing clean up, so took a quick crack at it. @aconchillo is this along the lines of what you were thinking for the TODO?

if self._input:
await self._input.push_error(ErrorFrame(error))
if self._output:
await self._output.push_error(ErrorFrame(error))
Copy link
Contributor

@aconchillo aconchillo Jan 18, 2025

Choose a reason for hiding this comment

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

I think it should be more like:

if self._input and self._output:
    await self._input.push_error(ErrorFrame(error))
elif self._input:
    await self._input.push_error(ErrorFrame(error))
else
    await self._output.push_error(ErrorFrame(error))

Copy link
Contributor

Choose a reason for hiding this comment

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

Or

if (self._input and self._output) or self._input:
    await self._input.push_error(ErrorFrame(error))
else
    await self._output.push_error(ErrorFrame(error))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about this?

if self._input is not None:
    await self._input.push_error(error_frame)
elif self._output is not None:
    await self._output.push_error(error_frame)
else:
    logger.error("Both input and output are None while trying to push error")
    raise RuntimeError("No valid input or output channel to push error")

Just pushed that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes! That would work. No need for is not None though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Approving

@markbackman markbackman force-pushed the mb/add-on-error-callback branch from ef95ca1 to 6c9c1e1 Compare January 18, 2025 02:35
@aconchillo
Copy link
Contributor

LGTM. Just added one nit comment

@markbackman markbackman force-pushed the mb/add-on-error-callback branch from 6c9c1e1 to e049ae4 Compare January 18, 2025 02:49
@markbackman markbackman merged commit 982f2be into main Jan 18, 2025
4 checks passed
@markbackman markbackman deleted the mb/add-on-error-callback branch January 18, 2025 02:59
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