Skip to content
engineering workbench.by StudyPort Academy
Learning path
Advanced18 min

Reading a real stack trace

Understand the idea

The message says what failed. The frames above it say which function threw, and which function called it.

The idea

starts with a failure you can locate. loadNote throws. getNote called it. handle called getNote. The run prints the message and those three names, top first. That is the walk: throw, then caller, then the route-level function. The HTTP example catches the same error and returns 500 with the message, so the client does not need the frame list. You still want the frames in the log when you are the one debugging. The Debug Library pages for a slow query, a bad model body, and a missing limit are the same kind of failure: they are readable when you know which function ran.

What changes

Line, meaning, and the next look
What you seeMeaningNext
note missing: 9The error textFind that string in the code
loadNoteThe function that threwRead that function
getNoteThe callerAsk why it called loadNote
handleThe entry from the routeMatch it to the request path

The command

Message and frames

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

500 with the message

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

The mistake

Check the result

The output run prints note missing: 9, then loadNote, getNote, and handle. The HTTP run is status 500 and the same message in JSON.

Guided challenge

Throw the note missing message

loadNote throws missing note 9. Change the message to note missing: 9 so it matches the stack-trace walk in the lesson.

Throw the note missing message

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

EXPECTED RESULT

note missing: 9
loadNote

Hints 0/2

    Use all hints or make 3 failed checks (0/3).

    Free exploration

    Change this example and run it again. Each run is a new process. Nothing is saved.

    Your variation

    3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

    Quiz

    A quick check for understanding. Retry as often as you like; your learning path stays open.

    01Which frame is the throw?
    02What should the client receive?

    Ready to call this one understood?

    Mark this lesson complete to earn 200 XP. You can always revisit it.

    Sign in to save progress
    Next lesson