Add error handling fundamentals to Data Groups Sprint 1 - #1949
Open
abdishakoor-dev wants to merge 13 commits into
Open
Add error handling fundamentals to Data Groups Sprint 1#1949abdishakoor-dev wants to merge 13 commits into
abdishakoor-dev wants to merge 13 commits into
Conversation
✅ Deploy Preview for cyf-common ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for cyf-curriculum ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
abdishakoor-dev
force-pushed
the
error-handling-fundamentals
branch
2 times, most recently
from
July 22, 2026 08:54
e21ffc4 to
8feddc2
Compare
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
force-pushed
the
error-handling-fundamentals
branch
from
July 22, 2026 08:59
8feddc2 to
70093be
Compare
illicitonion
left a comment
Member
There was a problem hiding this comment.
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?
abdishakoor-dev
added a commit
that referenced
this pull request
Jul 24, 2026
Matches review feedback on PR #1949.
abdishakoor-dev
force-pushed
the
error-handling-fundamentals
branch
from
July 24, 2026 08:35
12ca65f to
961a67b
Compare
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.
Contributor
Author
|
I've addressed all the inline comments in the last few commits. On the two follow-up questions, I've filed separate issues to track them rather than block this PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:
in Non-trivial tweaks to Data Flows sprints 2 and 3 #1111)
Preview: https://deploy-preview-1949--cyf-curriculum.netlify.app/itp/data-groups/sprints/1/prep/#throwing-errors