Closed FlynnOConnell closed 10 months ago
Creating a user that already exists gives:
{
"error": "Unique violation: duplicate key value violates unique constraint \"fluke_user_email_key\""
}
Creating a message with an invalid user_id
gives:
{
"error": "Foreign violation: insert or update on table \"message\" violates foreign key constraint \"fk_message_user_id\""
}
Though this shouldn't really happen. Many of the errors shouldn't happen but are logged anyway.
add 404. We should also probably consider changing the name of the error to something better than
CustomerError
. MaybeFlukeApiError
?
Added 404 and 401 UNAUTHORIZED for the future user authentication
CustomError
to handle specific PostgreSQL error types, providing clearer error messages for database violations.IntoResponse
implementation forCustomError
to ensure appropriate HTTP status codes and error messages are returned in API responses.From<SqlxError>
andIntoResponse
trait implementations.Errors to Handle
GET user
->Path(user_id)
|40X
CREATE user
->Json(credentials)
sqlx::Error
|409
+Location
header -> existing/conflicting resource?sqlx::Error
|403 Forbidden
?DELETE user
->Path(user_id)
|40X
user_id
doesn't exist shouldn't ever happenUPDATE user
->Path(user_id)
40X
user_id
doesn't exist shouldn't ever happen |40X
Signup
andLogin
user should be a bigger separate issuePath(user_id)
,Path(channel_id)
andPath(message_id)
references shouldn't be an issue on our end |40X
Tasks:
user
orchannel
deletion, Addresses #52Still more work to be done on error handling. There are more cases to cover and potentially a better implementation. Consider a more robust approach as is done here for the future.