Skip to content

Instantly share code, notes, and snippets.

@jbenet
Created May 10, 2014 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbenet/63bdbb52294c9858a959 to your computer and use it in GitHub Desktop.
Save jbenet/63bdbb52294c9858a959 to your computer and use it in GitHub Desktop.
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
try {
require('beep' + 'boop');
} catch (e) {
console.log(e);
console.log('e.code is: ' + e.code);
document.write(e);
document.write('<br />e.code is: ' + e.code);
if (e.code == 'MODULE_NOT_FOUND')
alert('Hm, it worked.');
}
},{}]},{},[1])
<!doctype html>
<html>
<head>
<script src="bundle.js"></script>
</head>
<body>
</body>
</html>
try {
require('beep' + 'boop');
} catch (e) {
console.log(e);
console.log('e.code is: ' + e.code);
document.write(e);
document.write('<br />e.code is: ' + e.code);
if (e.code == 'MODULE_NOT_FOUND')
alert('Hm, it worked.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment