Authoring skeleton - backend focus (CS112 backend fault tolerance)

Three short topics

  1. Validate input at the API boundary and reject bad data early.
  2. Checked vs unchecked exceptions and where to catch them.
  3. Meaningful error responses (4xx vs 5xx) without leaking internals.

PBL context

Send invalid input or a malformed import to a project feature and verify the reported error and unchanged valid data.

Backend layers to author

  • Identify what can go wrong in one existing endpoint.
  • Add validation and a clear exception for each failure.
  • Map exceptions to HTTP status codes and a consistent error body.
  • Close resources safely on every path.

Evidence checklist to author

Tests for null, empty, out-of-range, duplicate, and malformed input; each returns the expected status and message, and stored data is unchanged. Compare with the file-persistence draft for resource closure.

Publication checklist

Complete examples, a CodeRunner exercise, and tests before removing the draft/hide flags, enabling submissions, or confirming the course and week.

Code Runner Challenge

Authoring draft - api error handling exercise is not ready

View IPYNB Source
// CODE_RUNNER: Authoring draft - api error handling exercise is not ready
public class ApiErrorsDraft {
    public static void main(String[] args) {
        throw new UnsupportedOperationException("Draft: author the validation exercise and failure-path tests before publication.");
    }
}
ApiErrorsDraft.main(null);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...