Skip to content

Conversation

@sgao640
Copy link
Contributor

@sgao640 sgao640 commented Oct 30, 2025

@sgao640
Copy link
Contributor Author

sgao640 commented Oct 30, 2025

Summary

Improves error handling across the HTTP API by implementing structured, user-friendly error messages while preserving detailed internal logging.

Key Changes:

  • Handler updates: All error responses now use ToErrorMessage() to return formatted, caller-friendly messages instead of raw err.Error() output
  • Enhanced error types: Added ErrorMessage() and HTTPStatus() methods to ContentError, ObjectError, and StorageError for consistent error formatting
  • New sentinel errors: Added ErrMaxDerivationDepth, ErrNoStorageBackend, ErrNoObjectsFound, ErrNoUploadedObjects for better error categorization
  • Service layer improvements: Replaced generic fmt.Errorf with typed errors (ContentError, ObjectError) for proper error wrapping
  • Documentation: Added comprehensive ERROR_HANDLING.md guide

Benefits:

  • ✅ Better security - no longer exposes internal implementation details in API responses
  • ✅ Consistent error formatting across all endpoints
  • ✅ Appropriate HTTP status codes based on error type
  • ✅ Maintains detailed logging for debugging while showing clean messages to API consumers

Example:

Before: "parent content not found: sql: no rows in result set"
After:  "create_derived: content not found"

@livefire2015 livefire2015 merged commit 06415b9 into tendant:main Nov 3, 2025
1 of 7 checks passed
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