JS USER DEFINED ERROR EXAMPLE
Run
<!doctype html>
	<head>
		<title>User Defined Error Example</title>
	</head>
	<body>
		<p>User Defined Error Example</p>
		<script>
			/* JS comes here */
            function MyError(message) {
                this.name = 'MyError';
                this.message = message;
                this.stack = (new Error()).stack;
            }
            
            // throw this error
            throw new MyError("This is a custom error");
		</script>
	</body>
</html>