From ca77af3eacd67b84b6b500efc7466b798da9685b Mon Sep 17 00:00:00 2001 From: mewilker Date: Mon, 16 Mar 2026 18:52:12 -0600 Subject: [PATCH 1/2] add a section for database error handling --- chess/4-database/database.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chess/4-database/database.md b/chess/4-database/database.md index 10dc0a41..59ac3640 100644 --- a/chess/4-database/database.md +++ b/chess/4-database/database.md @@ -76,6 +76,13 @@ boolean verifyUser(String username, String providedClearTextPassword) { The above code demonstrates the necessary concepts to implement secure password storage, but it will need to be adapted to your particular implementation. You do not need to create a different table to store your passwords. The hashed password may be stored along with your other user information in your `user` table. +## Error Handling + +Now that your database is stored in MySQL, you must account for any errors trying to connect to that program. While your database is most likely kept on your own machine, it's possible that it could be kept on another. If the internet were to go down and the two programs are not able to establish a connection to each other, a `SQLException` would be thrown. + +If this happens while an endpoint is trying to access the database, this should be considered an `Internal Server Error`, and an appropriate response must be handled. +The status code must be set to `500` and the body of each of these responses must include a reasonable, relevant error message. You may recall this specification from [Phase 3](../3-web-api/web-api.md#endpoint-specifications). + ## ChessGame Serialization/Deserialization The easiest way to store the state of a ChessGame in MySQL is to serialize it to a JSON string, and then store the string in your database. Whenever your server needs to update the state of a game, it should: From 2eb3f1dea31689d17b4f33f7ccafcfca5bc64917 Mon Sep 17 00:00:00 2001 From: mewilker Date: Wed, 18 Mar 2026 18:49:19 -0600 Subject: [PATCH 2/2] edit error handling section to cut back on some explanation and fix formatting --- chess/4-database/database.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/chess/4-database/database.md b/chess/4-database/database.md index 59ac3640..c8bdde08 100644 --- a/chess/4-database/database.md +++ b/chess/4-database/database.md @@ -78,10 +78,7 @@ The above code demonstrates the necessary concepts to implement secure password ## Error Handling -Now that your database is stored in MySQL, you must account for any errors trying to connect to that program. While your database is most likely kept on your own machine, it's possible that it could be kept on another. If the internet were to go down and the two programs are not able to establish a connection to each other, a `SQLException` would be thrown. - -If this happens while an endpoint is trying to access the database, this should be considered an `Internal Server Error`, and an appropriate response must be handled. -The status code must be set to `500` and the body of each of these responses must include a reasonable, relevant error message. You may recall this specification from [Phase 3](../3-web-api/web-api.md#endpoint-specifications). +Now that your database is stored in MySQL, you must account for any errors trying to connect to that program. If any exception is thrown while an endpoint is trying to access the database, this should be considered an `Internal Server Error`, and an appropriate response must be handled. The status code must be set to `500` and the body of each of these responses must include a reasonable, relevant error message. You may recall this specification from [Phase 3](../3-web-api/web-api.md#endpoint-specifications). ## ChessGame Serialization/Deserialization