Skip to content

Replace error messages with predefined variables for Batch - #2641

Open
mike-sb wants to merge 1 commit into
jackc:masterfrom
mike-sb:feature/pgx-batch-errors
Open

mike-sb wants to merge 1 commit into
jackc:masterfrom
mike-sb:feature/pgx-batch-errors

Conversation

@mike-sb

@mike-sb mike-sb commented Aug 28, 2026

Copy link
Copy Markdown

Added predifined errors for batch funcs to consume them with errors.Is.

@mike-sb mike-sb changed the title Replace error messages with predefined variables Replace error messages with predefined variables for Batch Aug 28, 2026
@jackc

jackc commented Sep 7, 2026

Copy link
Copy Markdown
Owner

I'm not necessarily opposed to this, but I do have one concern.

In general, I think of named errors as existing because the caller is going to do something based on the type of error. But as far as I can tell, all of these errors are actually caller bugs. In that case, I don't see why the caller would check for them. If they happen the caller should be changed so they never occur.

But perhaps I'm missing some use case...

@mike-sb

mike-sb commented Sep 14, 2026

Copy link
Copy Markdown
Author

I'm not necessarily opposed to this, but I do have one concern.

In general, I think of named errors as existing because the caller is going to do something based on the type of error. But as far as I can tell, all of these errors are actually caller bugs. In that case, I don't see why the caller would check for them. If they happen the caller should be changed so they never occur.

But perhaps I'm missing some use case...

I encountered a case while processing a Batch where I wanted to check if it had finished. I couldn't use errors.Is for the comparison because a new error instance was created each time. It seems to me it would be better to iterate over the array of Batch responses rather than the original input array, since we are dealing with database behavior rather than user data.

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