Skip to content

Restore API error mapping for book placement failures #312

@leodvincci

Description

@leodvincci

Restore API error mapping for book placement failures

Type: API behavior
Priority: P1

Summary

Old controller mapped errors to HTTP status; new flow throws unchecked exceptions with no mapping.

Impact

500s for expected errors (book not found, shelf full, bad input).

Evidence

BookController.java now delegates; no exception handling.

@PostMapping("/{bookId}/shelf")
public ResponseEntity<HttpStatus> placeBookOnShelf(
    @PathVariable Long bookId, @RequestBody BookShelfAssignmentRequest shelfAssignmentRequest) {
  bookFacade.placeBookOnShelf(bookId, shelfAssignmentRequest);
  return ResponseEntity.ok(HttpStatus.OK);
}

Proposed Fix

Add @ControllerAdvice or reintroduce explicit mapping.

Acceptance Criteria

  • Errors map to 400/404/409 as appropriate.

Expected

Controller maps expected errors to correct HTTP status codes.

Actual

Unchecked exceptions bubble up as 500 for common error cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions