Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create custom errors for your JavaScript projects

License

NotificationsYou must be signed in to change notification settings

KhaledElAnsari/Hellrazor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create custom errors for your JavaScript projects

Installation

1- in browser:

<scriptsrc="/js/hellrazor.min.js"></script>

2- via NPM:

npm install hellrazor

Usage

You'll usecreateError() method to create an error, it takes two strings as parameters forError Name &Error Message and will return the new errorFunction

// if you have commonjs in your project// if not skip this linevarHellrazor=require("hellrazor");// The below is the same in any JavaScript environment (Browser or Node.js)vare=Hellrazor.createError("erropac","use hellrazor 'cause Chrome can't always be your savior");try{// you can re-assign the message if you wantthrownewe("new message");}catch(err){console.log(err.name);// erropacconsole.log(err.message);// new messageconsole.log(err.stack);console.log(errinstanceofError);// trueconsole.log(errinstanceofe);// true}

Extra

You can extra objects to the custom error usingprototype, for example the time when the error occurred

vare=Hellrazor.createError("errorName","errorMsg");try{e.prototype.happenAt=newDate();thrownewe();}catch(err){console.log(e.happenAt);}

License

This project is under the MIT license.

About

Create custom errors for your JavaScript projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp