LukeBrandon / fluke

5 stars 0 forks source link

chore: enhance custom error handling and documentation #57

Closed FlynnOConnell closed 10 months ago

FlynnOConnell commented 11 months ago

Errors to Handle

  1. Users
  1. Channels
  1. Messages

Tasks:

Still 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.

FlynnOConnell commented 11 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.

FlynnOConnell commented 10 months ago

add 404. We should also probably consider changing the name of the error to something better than CustomerError. Maybe FlukeApiError?

Added 404 and 401 UNAUTHORIZED for the future user authentication