[pkgsite] internal/api: refactor error handling to increase consistency

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Apr 9, 2026, 4:23:09 PM (11 hours ago) Apr 9
to Ethan Lee, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Jonathan Amsterdam, kokoro, Go LUCI, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
internal/api: refactor error handling to increase consistency

- Refactored error handling to avoid leaking internal implementation
details. Database and system errors are masked by falling back to
standard HTTP statuses but still logging the entire error context.
- User facing error messages can now be specified within the Error
struct.
- Added helpers in types.go to simplify error construction.
- Updated ServeModuleVersions to explicitly return 404 when no versions
are found.
- Expanded test coverage in api_test.go to include 404 and 400 edge
cases.
Change-Id: I89c4be3941126c15df6aefdd21e4bbd2d3b23be1
Auto-Submit: Ethan Lee <etha...@google.com>
kokoro-CI: kokoro <noreply...@google.com>
Reviewed-by: Jonathan Amsterdam <j...@google.com>
Files:
  • M internal/api/api.go
  • M internal/api/api_test.go
  • M internal/api/params.go
  • M internal/api/types.go
  • M internal/frontend/server.go
Change size: M
Delta: 5 files changed, 130 insertions(+), 38 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Jonathan Amsterdam
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
  • requirement satisfiedkokoro-CI-Passes: kokoro-CI+1 by kokoro
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: pkgsite
Gerrit-Branch: master
Gerrit-Change-Id: I89c4be3941126c15df6aefdd21e4bbd2d3b23be1
Gerrit-Change-Number: 764820
Gerrit-PatchSet: 2
Gerrit-Owner: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Ethan Lee <etha...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: kokoro <noreply...@google.com>
Gerrit-CC: kokoro <noreply...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages