\href{https://npmjs.org/package/make-error}{\texttt{ }} \href{https://travis-ci.org/JsCommunity/make-error}{\texttt{ }} \href{https://packagephobia.now.sh/result?p=make-error}{\texttt{ }} \href{https://github.com/JsCommunity/make-error/commits/master}{\texttt{ }}

\begin{quote}
Make your own error types! \end{quote}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16470}{}\doxysection{Features}\label{md_sfcode_node_modules_make_error_README_autotoc_md16470}

\begin{DoxyItemize}
\item Compatible Node \& browsers
\item {\ttfamily instanceof} support
\item {\ttfamily error.\+name} \& {\ttfamily error.\+stack} support
\item compatible with \href{https://en.wikipedia.org/wiki/Content_Security_Policy}{\texttt{ CSP}} (i.\+e. no {\ttfamily eval()})
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16471}{}\doxysection{Installation}\label{md_sfcode_node_modules_make_error_README_autotoc_md16471}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16472}{}\doxysubsection{Node \& $<$a href=\char`\"{}http\+://browserify.\+org/\char`\"{}$>$\+Browserify$<$/a$>$/$<$a href=\char`\"{}https\+://webpack.\+js.\+org/\char`\"{}$>$\+Webpack$<$/a$>$}\label{md_sfcode_node_modules_make_error_README_autotoc_md16472}
Installation of the \href{https://npmjs.org/package/make-error}{\texttt{ npm package}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{> npm install -\/-\/save make-\/error }

\end{DoxyCode}


Then require the package\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var makeError = require("{}make-\/error"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16473}{}\doxysubsection{Browser}\label{md_sfcode_node_modules_make_error_README_autotoc_md16473}
You can directly use the build provided at \href{https://unpkg.com}{\texttt{ unpkg.\+com}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}https://unpkg.com/make-\/error@1/dist/make-\/error.js"{}></script> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16474}{}\doxysection{Usage}\label{md_sfcode_node_modules_make_error_README_autotoc_md16474}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16475}{}\doxysubsection{Basic named error}\label{md_sfcode_node_modules_make_error_README_autotoc_md16475}

\begin{DoxyCode}{0}
\DoxyCodeLine{var CustomError = makeError("{}CustomError"{});}
\DoxyCodeLine{}
\DoxyCodeLine{// Parameters are forwarded to the super class (here Error).}
\DoxyCodeLine{throw new CustomError("{}a message"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16476}{}\doxysubsection{Advanced error class}\label{md_sfcode_node_modules_make_error_README_autotoc_md16476}

\begin{DoxyCode}{0}
\DoxyCodeLine{function CustomError(customValue) \{}
\DoxyCodeLine{  CustomError.super.call(this, "{}custom error message"{});}
\DoxyCodeLine{}
\DoxyCodeLine{  this.customValue = customValue;}
\DoxyCodeLine{\}}
\DoxyCodeLine{makeError(CustomError);}
\DoxyCodeLine{}
\DoxyCodeLine{// Feel free to extend the prototype.}
\DoxyCodeLine{CustomError.prototype.myMethod = function CustomError\$myMethod() \{}
\DoxyCodeLine{  console.log("{}CustomError.myMethod (\%s, \%s)"{}, this.code, this.message);}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{//-\/-\/-\/-\/-\/}
\DoxyCodeLine{}
\DoxyCodeLine{try \{}
\DoxyCodeLine{  throw new CustomError(42);}
\DoxyCodeLine{\} catch (error) \{}
\DoxyCodeLine{  error.myMethod();}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16477}{}\doxysubsection{Specialized error}\label{md_sfcode_node_modules_make_error_README_autotoc_md16477}

\begin{DoxyCode}{0}
\DoxyCodeLine{var SpecializedError = makeError("{}SpecializedError"{}, CustomError);}
\DoxyCodeLine{}
\DoxyCodeLine{throw new SpecializedError(42); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16478}{}\doxysubsection{Inheritance}\label{md_sfcode_node_modules_make_error_README_autotoc_md16478}
\begin{quote}
Best for ES2015+. \end{quote}

\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ BaseError \} from "{}make-\/error"{};}
\DoxyCodeLine{}
\DoxyCodeLine{class CustomError extends BaseError \{}
\DoxyCodeLine{  constructor() \{}
\DoxyCodeLine{    super("{}custom error message"{});}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16479}{}\doxysection{Related}\label{md_sfcode_node_modules_make_error_README_autotoc_md16479}

\begin{DoxyItemize}
\item \href{https://www.npmjs.com/package/make-error-cause}{\texttt{ make-\/error-\/cause}}\+: Make your own error types, with a cause!
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16480}{}\doxysection{Contributions}\label{md_sfcode_node_modules_make_error_README_autotoc_md16480}
Contributions are {\itshape very} welcomed, either on the documentation or on the code.

You may\+:


\begin{DoxyItemize}
\item report any \href{https://github.com/JsCommunity/make-error/issues}{\texttt{ issue}} you\textquotesingle{}ve encountered;
\item fork and create a pull request.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_error_README_autotoc_md16481}{}\doxysection{License}\label{md_sfcode_node_modules_make_error_README_autotoc_md16481}
ISC © \href{http://julien.isonoe.net}{\texttt{ Julien Fontanet}} 