API Reference

p-try

If the function throws an error, the returned Promise will be rejected with that error.

Official Documentation ↗
CompatibilityThis documentation covers version v3.0.0. Check the official docs for the latest API surface.

Installation

npmnpm install p-try
pnpmpnpm add p-try

Methods

Overview

If the function throws an error, the returned Promise will be rejected with that error. Support for passing arguments on to the fn is provided in order to be able to avoid creating unnecessary closures.

API reference status

This page lists only entry points that appear verbatim in the official README examples: pTry, error. Parameter and return types are not given by the official README, so signatures are marked unverified.

Verification notes

API reference evidence

Fetched from official sources on 2026-11-08T18:21:00+08:00 via WebFetch https://cdn.jsdelivr.net/gh/sindresorhus/p-try@latest/readme.md(raw.githubusercontent.com 分支抓取返回空后改用官方 README 镜像).

FAQ

What does p-try do?
If the function throws an error, the returned Promise will be rejected with that error.
How do I install p-try?
Run `npm install p-try`.
Where can I verify the API details?
Official repository/documentation: https://github.com/sindresorhus/p-try. Checked on 2026-11-04; signatures and return values not stated in the official README are marked unverified.