Skip to content

Add error handling fundamentals to Data Groups Sprint 1 - #1949

Open
abdishakoor-dev wants to merge 13 commits into
mainfrom
error-handling-fundamentals
Open

Add error handling fundamentals to Data Groups Sprint 1#1949
abdishakoor-dev wants to merge 13 commits into
mainfrom
error-handling-fundamentals

Conversation

@abdishakoor-dev

@abdishakoor-dev abdishakoor-dev commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

First attempt for #1946

Adds three js2 blocks (Throwing errors, try/catch, Throw or return?) that teach exceptions and error handling using the existing calculateMedian exercise, and wires them into Data Groups Sprint 1
prep, after "Implementing all the cases".

Trainees currently learn fetch, promises, and async/await without ever being taught how to throw or catch an error. This covers the synchronous foundation.

Two follow ups needed once this lands:

Preview: https://deploy-preview-1949--cyf-curriculum.netlify.app/itp/data-groups/sprints/1/prep/#throwing-errors

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-common ready!

Name Link
🔨 Latest commit 1e2acc3
🔍 Latest deploy log https://app.netlify.com/projects/cyf-common/deploys/6a8714fba414a200084ba848
😎 Deploy Preview https://deploy-preview-1949--cyf-common.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-curriculum ready!

Name Link
🔨 Latest commit 1e2acc3
🔍 Latest deploy log https://app.netlify.com/projects/cyf-curriculum/deploys/6a8714fbf4a86f000881c0d3
😎 Deploy Preview https://deploy-preview-1949--cyf-curriculum.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 85 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@abdishakoor-dev
abdishakoor-dev force-pushed the error-handling-fundamentals branch 2 times, most recently from e21ffc4 to 8feddc2 Compare July 22, 2026 08:54
Trainees currently learn fetch, promises, and async/await without
being taught how to throw or catch an error. Adds three js2 blocks
(throwing errors, try/catch, throw vs return) built around the
existing calculateMedian exercise, and wires them into Sprint 1 prep.

Refs #1946
@abdishakoor-dev
abdishakoor-dev force-pushed the error-handling-fundamentals branch from 8feddc2 to 70093be Compare July 22, 2026 08:59

@illicitonion illicitonion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left a few minor comments.

Exercise-wise, as well as updating the existing ones, do we want to add a few new exercises to get people throwing and catching more?

Also, do we want to add a callback to this in https://curriculum.codeyourfuture.io/sdc/tools/sprints/5/prep/ to reflect on static checking being better than dynamic checking?

Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throwing-errors/index.md
Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throwing-errors/index.md Outdated
Comment thread common-content/en/module/js2/throw-or-return/index.md
Comment thread common-content/en/module/js2/throw-or-return/index.md
Comment thread common-content/en/module/js2/throw-or-return/index.md Outdated
abdishakoor-dev added a commit that referenced this pull request Jul 24, 2026
@abdishakoor-dev
abdishakoor-dev force-pushed the error-handling-fundamentals branch from 12ca65f to 961a67b Compare July 24, 2026 08:35
Matches review feedback: the guarded implementation checked the
input was a non-empty array, but not that its elements were
numbers, so calculateMedian(["a", "b"]) would still silently
return nonsense.
Calling with no argument does crash on its own (list is undefined),
but with a generic engine error that doesn't mention calculateMedian
or say a list was expected. The existing non-array guard already
catches this case, so add an example and test showing that.
toThrow(string) only checks the message contains a substring, not
that it equals it. toThrow(new Error(...)) is Jest's documented way
to assert the exact message, more precise given we now write the
messages ourselves. Also add the missing non-array test case, and
bump time to 20 minutes to reflect the added content.
@abdishakoor-dev

abdishakoor-dev commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

I've addressed all the inline comments in the last few commits.

Preview: https://deploy-preview-1949--cyf-curriculum.netlify.app/itp/data-groups/sprints/1/prep/#throwing-errors

On the two follow-up questions, I've filed separate issues to track them rather than block this PR:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋 Backlog

Development

Successfully merging this pull request may close these issues.

2 participants