0
0
Spring Bootframework~10 mins

Problem Details for standard error format in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Problem Details response with a title.

Spring Boot
ProblemDetail problem = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
problem.set[1]("Invalid input");
Drag options to blanks, or click blank then click option'
AsetError
BsetMessage
CsetTitle
DsetDescription
Attempts:
3 left
💡 Hint
Common Mistakes
Using setMessage instead of setTitle
Trying to set description instead of title
2fill in blank
medium

Complete the code to add a detailed error message to the ProblemDetail.

Spring Boot
problem.set[1]("The provided ID is not valid.");
Drag options to blanks, or click blank then click option'
AsetInstance
BsetTitle
CsetStatus
DsetDetail
Attempts:
3 left
💡 Hint
Common Mistakes
Using setTitle instead of setDetail
Trying to set status instead of detail
3fill in blank
hard

Fix the error in setting the HTTP status code for the ProblemDetail.

Spring Boot
problem.setStatus(HttpStatus.[1]);
Drag options to blanks, or click blank then click option'
ABAD_REQUEST.value()
BBAD_REQUEST
C400
DNOT_FOUND
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an integer status code instead of HttpStatus enum
Calling .value() method inside setStatus
4fill in blank
hard

Fill both blanks to create a ProblemDetail with a custom type URI and instance URI.

Spring Boot
problem.set[1](URI.create("https://example.com/probs/invalid-input"));
problem.set[2](URI.create("/orders/1234"));
Drag options to blanks, or click blank then click option'
AsetType
BsetTitle
CsetInstance
DsetDetail
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up setTitle and setType
Using setDetail instead of setInstance
5fill in blank
hard

Fill all three blanks to create a ProblemDetail with title, detail, and status.

Spring Boot
problem.set[1]("Unauthorized access");
problem.set[2]("You must log in to access this resource.");
problem.set[3](HttpStatus.UNAUTHORIZED);
Drag options to blanks, or click blank then click option'
AsetTitle
BsetDetail
CsetStatus
DsetInstance
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing setInstance with setStatus
Using setDetail for the title