Challenge - 5 Problems
Nested Error Reporting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of this nested error response JSON?
Given this nested error response from a REST API, what is the value of the message field inside the
details object?Rest API
{
"error": {
"code": 400,
"message": "Validation Failed",
"details": {
"field": "email",
"message": "Invalid email format"
}
}
}Attempts:
2 left
💡 Hint
Look inside the nested 'details' object for the 'message' field.
✗ Incorrect
The 'message' inside 'details' is 'Invalid email format'. The outer 'message' is 'Validation Failed'.
❓ Predict Output
intermediate1:30remaining
What HTTP status code is returned in this nested error response?
Look at this nested error response JSON. What is the HTTP status code indicated by the
status field inside the error object?Rest API
{
"error": {
"status": 404,
"message": "Resource not found",
"details": {
"resource": "user",
"id": "123"
}
}
}Attempts:
2 left
💡 Hint
The status code is usually a number inside the 'error' object.
✗ Incorrect
The 'status' field inside 'error' is 404, which is the HTTP status code.
🔧 Debug
advanced2:00remaining
Which option causes a JSON parsing error?
One of these nested error response JSON strings is invalid and will cause a parsing error. Which one?
Attempts:
2 left
💡 Hint
Look for missing or extra brackets in the JSON strings.
✗ Incorrect
Option C is missing the closing brace for the outer 'error' object, causing a JSON parsing error.
🧠 Conceptual
advanced1:30remaining
What is the main benefit of nesting error details in REST API responses?
Why do REST APIs often nest detailed error information inside an 'error' object rather than placing all fields at the top level?
Attempts:
2 left
💡 Hint
Think about clarity and structure in data.
✗ Incorrect
Nesting error details helps keep error info organized and separate from normal data, making it easier to parse and understand.
❓ Predict Output
expert2:00remaining
What is the value of 'error.details.errors[1].message' in this nested error response?
Given this nested error response JSON, what is the value of the second error message inside the 'errors' list?
Rest API
{
"error": {
"code": 422,
"message": "Validation Error",
"details": {
"errors": [
{"field": "username", "message": "Required field"},
{"field": "password", "message": "Too short"},
{"field": "email", "message": "Invalid format"}
]
}
}
}Attempts:
2 left
💡 Hint
Remember that list indexes start at 0.
✗ Incorrect
The second error in the 'errors' list (index 1) has the message 'Too short'.