# vtry

> tryit + verror = Verbosely try.

Latest version **1.1.1** (published 2026-04-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install vtry
pnpm add vtry
yarn add vtry
bun add vtry
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-04-20 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=24.15.0 |
| Dependencies | 1 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M.K. |
| Maintainers | mk-pmb |
| Keywords | error, errors, try |

## Links

- npm: https://www.npmjs.com/package/vtry
- Repository: https://github.com/mk-pmb/vtry-js
- Homepage: https://github.com/mk-pmb/vtry-js/#readme
- Issues: https://github.com/mk-pmb/vtry-js/issues
- npm.io page: https://npm.io/package/vtry

## Dependencies (1)

- [verror](https://npm.io/package/verror.md) ^1.10.0

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2026-04-20
- 1.1.0 — 2026-04-06
- 1.0.9 — 2022-07-25
- 1.0.8 — 2022-04-04
- 1.0.7 — 2021-07-15
- 1.0.6 — 2020-07-27
- 1.0.5 — 2020-05-05
- 1.0.4 — 2019-01-19
- 1.0.3 — 2019-01-10
- 1.0.2 — 2018-09-04
- 1.0.1 — 2018-07-22
- 1.0.0 — 2018-07-22

## README

<!--#echo json="package.json" key="name" underline="=" -->
vtry
====
<!--/#echo -->

<!--#echo json="package.json" key="description" -->
tryit + verror = Verbosely try.
<!--/#echo -->




API
---

This module exports one function that can be called in several ways
described below. In each case,

* `f` is the original function that might throw.
* `g` is a proxy function that wraps `f`, preserving context (`this`)
  and arguments. If no error is thrown, it forwards the result.


### g = vtry(f)

Errors are silently ignored.


### g = vtry(f, hnd[, ...args])

In case of an error, return `hnd(err, ...args)`.


### g = vtry(f, errMsg[, errOpt])

* Required prior knowledge: [verror](https://www.npmjs.com/package/verror)

Decorate potentially-cryptic errors with an error message `errMsg` that
ideally describes what operation you were trying to perform.
`errMsg` must be either a non-empty string or an array.
It will be used as the `sprintf_args` to `VError`.
`errOpt` are the `options` as described in `VError`.



&nbsp;

### Promise API

There's also a method `vtry.pr` ("Promise") which works almost as above,
except it takes an async function `f` and returns an async function `g`.
As a special convenience, supplying `1` (the number) as `f` is a shorthand
for the identity function, so you can easily pass existing promises to `g`.






<!--#toc stop="scan" -->



Known issues
------------

* Needs more/better tests and docs.




&nbsp;


License
-------
<!--#echo json="package.json" key=".license" -->
ISC
<!--/#echo -->

---
_Source: https://npm.io/package/vtry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
