\begin{quote}
Start a promise chain \end{quote}
\href{http://cryto.net/~joepie91/blog/2016/05/11/what-is-promise-try-and-why-does-it-matter/}{\texttt{ How is it useful?}}\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19334}{}\doxysection{Install}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19334}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install p-\/try }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19335}{}\doxysection{Usage}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19335}

\begin{DoxyCode}{0}
\DoxyCodeLine{const pTry = require('p-\/try');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    try \{}
\DoxyCodeLine{        const value = await pTry(() => \{}
\DoxyCodeLine{            return synchronousFunctionThatMightThrow();}
\DoxyCodeLine{        \});}
\DoxyCodeLine{        console.log(value);}
\DoxyCodeLine{    \} catch (error) \{}
\DoxyCodeLine{        console.error(error);}
\DoxyCodeLine{    \}}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19336}{}\doxysection{API}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19336}
\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19337}{}\doxysubsection{p\+Try(fn, ...\+arguments)}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19337}
Returns a {\ttfamily Promise} resolved with the value of calling {\ttfamily fn(...\+arguments)}. If the function throws an error, the returned {\ttfamily Promise} will be rejected with that error.

Support for passing arguments on to the {\ttfamily fn} is provided in order to be able to avoid creating unnecessary closures. You probably don\textquotesingle{}t need this optimization unless you\textquotesingle{}re pushing a {\itshape lot} of functions.\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19338}{}\doxysubsubsection{fn}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19338}
The function to run to start the promise chain.\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19339}{}\doxysubsubsection{arguments}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19339}
Arguments to pass to {\ttfamily fn}.\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19340}{}\doxysection{Related}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19340}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/p-finally}{\texttt{ p-\/finally}} -\/ {\ttfamily Promise\#finally()} ponyfill -\/ Invoked when the promise is settled regardless of outcome
\item \href{https://github.com/sindresorhus/promise-fun}{\texttt{ More…}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_p_try_readme_autotoc_md19341}{}\doxysection{License}\label{md_sfcode_node_modules_p_try_readme_autotoc_md19341}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 