A panic ends the current program thread when an operation cannot be handled. Calling unwrap on a failed database operation panics and exits instead of returning an error to the API handler. section 5.4
Course retrieval API
A course query initially uses .fetch_all(pool).await?.unwrap(); the unwrap can panic when the database operation fails. Replacing it with .await? and returning Result<Vec<Course>, EzyTutorError> propagates the failure so the handler can produce an HTTP error.
The production concern is straightforward:
- Use panic-producing unwrap only when terminating execution is acceptable; otherwise return or propagate a Result. section 5.4







