Skip to content

[cli] create printError utility#12010

Merged
kodiakhq[bot] merged 3 commits intomainfrom
erikarowland/zero-2439-refactor-handleerror-to-use-output
Sep 20, 2024
Merged

[cli] create printError utility#12010
kodiakhq[bot] merged 3 commits intomainfrom
erikarowland/zero-2439-refactor-handleerror-to-use-output

Conversation

@erikareads
Copy link
Copy Markdown
Contributor

@erikareads erikareads commented Aug 23, 2024

This PR creates printError a refactored version of handleError that uses Output instead of console.error, and renames the function to better represent its use.

handleError didn't do any error handling, only output, but didn't use the existing utilities in client.output to accomplish that. This PR also fixes a 7 year old bug where 'Canceled' was never printed to users.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 23, 2024

🦋 Changeset detected

Latest commit: abd7575

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@erikareads
Copy link
Copy Markdown
Contributor Author

import { getCommandName } from './pkg-name';
import { type Output } from './output/create-output';

export function printError(error: unknown, output: Output) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (soft-blocking): can we make to use this somewhere in this PR or a quick follow up?

I don't like adding unused code because it can sometimes stay that way.

} else {
output.error(`Unexpected error. Please try again later. (${message})`);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (soft-blocking): Can we add some tests for all of this behavior?

error = new Error(error);
}

const apiError = error as APIError;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (soft-blocking): Can we remove the type assertion and use type checking instead?

@kodiakhq kodiakhq bot merged commit 9411076 into main Sep 20, 2024
@kodiakhq kodiakhq bot deleted the erikarowland/zero-2439-refactor-handleerror-to-use-output branch September 20, 2024 23:15
TooTallNate pushed a commit that referenced this pull request Sep 23, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/[email protected]

### Patch Changes

- Allow Node.js v22 behind env var feature flag
([#12159](#12159))

## [email protected]

### Patch Changes

- Change error printing to use standard Output methods
([#12010](#12010))

- Updated dependencies
\[[`2dab096e952c25521bac2537039ed7ca15675095`](2dab096)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`2dab096e952c25521bac2537039ed7ca15675095`](2dab096)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`2dab096e952c25521bac2537039ed7ca15675095`](2dab096)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`2dab096e952c25521bac2537039ed7ca15675095`](2dab096)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/[email protected]

## @vercel-internals/[email protected]

### Patch Changes

- Updated dependencies
\[[`2dab096e952c25521bac2537039ed7ca15675095`](2dab096)]:
    -   @vercel/[email protected]
kodiakhq bot pushed a commit that referenced this pull request Sep 27, 2024
This PR standardizes most remaining `console.error(error())` invocations to use `output.error` instead. `handleError` is left unchanged in this PR because it's already addressed with the creation of `prettyError` in #12010. 

This PR alters a number of call signatures to pass `output` into the appropriate functions.
github-merge-queue bot pushed a commit that referenced this pull request Jan 3, 2025
Previously #12010 I created `printError` to begin changing the API of
`handleError` to use `output` instead of directly using `console.error`.
Since we're now importing a usable `output` object directly,
`handleError` can be updated without changing its call signature. This
PR moves the updates from `printError` into `handleError` and removes
the now redundant `printError`.
QuietCraftsmanship pushed a commit to QuietCraftsmanship/Vercel that referenced this pull request Jul 6, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/[email protected]

### Patch Changes

- Allow Node.js v22 behind env var feature flag
([#12159](vercel/vercel#12159))

## [email protected]

### Patch Changes

- Change error printing to use standard Output methods
([#12010](vercel/vercel#12010))

- Updated dependencies
\[[`a2ca868b10f685d4e63aaf8325801606c4158759`](vercel/vercel@a2ca868)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`a2ca868b10f685d4e63aaf8325801606c4158759`](vercel/vercel@a2ca868)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`a2ca868b10f685d4e63aaf8325801606c4158759`](vercel/vercel@a2ca868)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`a2ca868b10f685d4e63aaf8325801606c4158759`](vercel/vercel@a2ca868)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/[email protected]

## @vercel-internals/[email protected]

### Patch Changes

- Updated dependencies
\[[`a2ca868b10f685d4e63aaf8325801606c4158759`](vercel/vercel@a2ca868)]:
    -   @vercel/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants