Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING(assert): make unreachable() consistent with @std/assert #4943

Merged
merged 5 commits into from
Jun 3, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Jun 3, 2024

What's changed

This change changes the format of the error message thrown in unreachable() to consistent with the rest of @std/assert. It also capitalizes the first letter of the error message.

Why this change was made

Previously, the format of the error message unreachable() threw didn't have the message suffix, given by the msg argument, at the end of the message string, which is what the rest of @std/assert. This change was made for consistency.

Migration guide

To migrate, update the logic that handles the error message:

import { unreachable } from "@std/assert/unreachable";

try {
  unreachable("Hello");
} catch (error) {
- if (error.message === "Hello") {
+ if (error.message === "Unreachable: Hello") {
    foo();
  }
}

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.15%. Comparing base (a5a658f) to head (fa8e6a0).
Report is 1 commits behind head on main.

Current head fa8e6a0 differs from pull request most recent head 57e29d4

Please upload reports for the commit 57e29d4 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4943   +/-   ##
=======================================
  Coverage   92.15%   92.15%           
=======================================
  Files         487      487           
  Lines       38768    38769    +1     
  Branches     5390     5390           
=======================================
+ Hits        35725    35726    +1     
  Misses       2987     2987           
  Partials       56       56           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iuioiua iuioiua marked this pull request as ready for review June 3, 2024 13:23
@iuioiua iuioiua requested a review from kt3k as a code owner June 3, 2024 13:23
@github-actions github-actions bot removed the io label Jun 3, 2024
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@iuioiua iuioiua enabled auto-merge (squash) June 3, 2024 13:31
@iuioiua iuioiua merged commit c2b5460 into main Jun 3, 2024
10 checks passed
@iuioiua iuioiua deleted the assert-unreachable-3 branch June 3, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants