Last active
June 1, 2025 19:33
-
-
Save Integralist/1599546 to your computer and use it in GitHub Desktop.
Error Handling with RequireJs #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(function(){ | |
| return function(errObject) { | |
| requireType = errObject.requireType; | |
| requireModules = errObject.requireModules.trim().split(' '); | |
| console.log(requireType, requireModules); | |
| }; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require.config({ | |
| catchError: { | |
| define: true | |
| } | |
| }); | |
| require(['errorhandler'], function(handler) { | |
| console.log('error handler loaded'); | |
| require.onError = handler; | |
| }); | |
| require(['module-with-dependancy-issue'], function(mod) { | |
| console.log(mod); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html dir="ltr" lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Require Js</title> | |
| </head> | |
| <body> | |
| <h1>Error Handling</h1> | |
| <script data-main="Assets/Scripts/example-error-handling" src="Assets/Scripts/Require.min.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(['this-doesnt-exist'], function(){ | |
| return 'my module'; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do I avoid this error