Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unjs/h3
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.7.11
Choose a base ref
...
head repository: unjs/h3
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.7.12
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 21, 2022

  1. fix(isError): use __h3_error__ class property to detect error

    soves issue with multiple h3 instances or builds
    pi0 committed Jul 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    968bfee View commit details
  2. chore(release): 0.7.12

    pi0 committed Jul 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e27f673 View commit details
Showing with 11 additions and 3 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +3 −2 src/error.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.7.12](https://github.com/unjs/h3/compare/v0.7.11...v0.7.12) (2022-07-21)


### Bug Fixes

* **isError:** use `__h3_error__` class property to detect error ([968bfee](https://github.com/unjs/h3/commit/968bfeef8ea728497bf432c421bbb73f3e9de6e7))

### [0.7.11](https://github.com/unjs/h3/compare/v0.7.10...v0.7.11) (2022-07-21)


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "h3",
"version": "0.7.11",
"version": "0.7.12",
"description": "Tiny JavaScript Server",
"repository": "unjs/h3",
"license": "MIT",
5 changes: 3 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import { MIMES } from './utils'
* @property {Boolean} internal Setting this property to <code>true</code> will mark error as an internal error
*/
export class H3Error extends Error {
static __h3_error__ = true
statusCode: number = 500
fatal: boolean = false
unhandled: boolean = false
@@ -32,7 +33,7 @@ export function createError (input: string | Partial<H3Error>): H3Error {
return new H3Error(input)
}

if (input instanceof H3Error) {
if (isError(input)) {
return input
}

@@ -81,5 +82,5 @@ export function sendError (event: CompatibilityEvent, error: Error | H3Error, de
}

export function isError (input: any): input is H3Error {
return input instanceof H3Error
return input?.constructor?.__h3_error__ === true
}