@use-services/httperr
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

HttpErr

// in services.ts
import * as Echo from "@use-services/echo";

import * as errcodes from "@/errcodes";

const options = {
  errs: {
    init: HttpErr.init,
    args: errcodes,
  } as HttpErr.Option<typeof errcodes>,
};

// in errcodes.ts
const ErrCodes = {
  ErrInternal: {
    status: 500,
    message: "${message}",
    args: {
      message: "server error",
    },
  },
  ErrValidation: {
    status: 400,
    message: "validate failed",
  },
}

// usage
throw srvs.errs.ErrValidation.toError();

Readme

Keywords

Package Sidebar

Install

npm i @use-services/httperr

Weekly Downloads

4

Version

1.3.3

License

MIT

Unpacked Size

4.97 kB

Total Files

4

Last publish

Collaborators

  • sigoden