\href{https://npmjs.org/package/err-code}{\texttt{ }} \href{https://npmjs.org/package/err-code}{\texttt{ }} \href{https://travis-ci.org/IndigoUnited/js-err-code}{\texttt{ }} \href{https://david-dm.org/IndigoUnited/js-err-code}{\texttt{ }} \href{https://david-dm.org/IndigoUnited/js-err-code\#info=devDependencies}{\texttt{ }}

Create new error instances with a code and additional properties.\hypertarget{md_sfcode_node_modules_err_code_README_autotoc_md8752}{}\doxysection{Installation}\label{md_sfcode_node_modules_err_code_README_autotoc_md8752}
{\ttfamily \$ npm install err-\/code} -\/ {\ttfamily NPM} ~\newline
 {\ttfamily \$ bower install err-\/code} -\/ {\ttfamily bower}

The browser file is named index.\+umd.\+js which supports Common\+JS, AMD and globals (err\+Code).\hypertarget{md_sfcode_node_modules_err_code_README_autotoc_md8753}{}\doxysection{Why}\label{md_sfcode_node_modules_err_code_README_autotoc_md8753}
I find myself doing this repeatedly\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var err = new Error('My message');}
\DoxyCodeLine{err.code = 'SOMECODE';}
\DoxyCodeLine{err.detail = 'Additional information about the error';}
\DoxyCodeLine{throw err; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_err_code_README_autotoc_md8754}{}\doxysection{Usage}\label{md_sfcode_node_modules_err_code_README_autotoc_md8754}
Simple usage.


\begin{DoxyCode}{0}
\DoxyCodeLine{var errcode = require('err-\/code');}
\DoxyCodeLine{}
\DoxyCodeLine{// fill error with message + code}
\DoxyCodeLine{throw errcode(new Error('My message'), 'ESOMECODE');}
\DoxyCodeLine{// fill error with message + code + props}
\DoxyCodeLine{throw errcode(new Error('My message'), 'ESOMECODE', \{ detail: 'Additional information about the error' \});}
\DoxyCodeLine{// fill error with message + props}
\DoxyCodeLine{throw errcode(new Error('My message'), \{ detail: 'Additional information about the error' \});}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{// You may also pass a string in the first argument and an error will be automatically created}
\DoxyCodeLine{// for you, though the stack trace will contain err-\/code in it.}
\DoxyCodeLine{}
\DoxyCodeLine{// create error with message + code}
\DoxyCodeLine{throw errcode('My message', 'ESOMECODE');}
\DoxyCodeLine{// create error with message + code + props}
\DoxyCodeLine{throw errcode('My message', 'ESOMECODE', \{ detail: 'Additional information about the error' \});}
\DoxyCodeLine{// create error with message + props}
\DoxyCodeLine{throw errcode('My message', \{ detail: 'Additional information about the error' \}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_err_code_README_autotoc_md8755}{}\doxysection{Tests}\label{md_sfcode_node_modules_err_code_README_autotoc_md8755}
{\ttfamily \$ npm test}\hypertarget{md_sfcode_node_modules_err_code_README_autotoc_md8756}{}\doxysection{License}\label{md_sfcode_node_modules_err_code_README_autotoc_md8756}
Released under the \href{http://www.opensource.org/licenses/mit-license.php}{\texttt{ MIT License}}. 