forked from processing/p5.js-sound
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04288f2
commit d6c2102
Showing
7 changed files
with
112 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
define(function (require) { | ||
'use strict'; | ||
|
||
/** | ||
* Helper function to generate an error | ||
* with a custom stack trace that points to the sketch | ||
* and removes other parts of the stack trace. | ||
* | ||
* @private | ||
* | ||
* @param {String} name custom error name | ||
* @param {String} errorTrace custom error trace | ||
* @param {String} failedPath path to the file that failed to load | ||
* @property {String} name custom error name | ||
* @property {String} message custom error message | ||
* @property {String} stack trace the error back to a line in the user's sketch. | ||
* Note: this edits out stack trace within p5.js and p5.sound. | ||
* @property {String} originalStack unedited, original stack trace | ||
* @property {String} failedPath path to the file that failed to load | ||
* @return {Error} returns a custom Error object | ||
*/ | ||
var CustomError = function(name, errorTrace, failedPath) { | ||
var err = new Error(); | ||
var tempStack, splitStack; | ||
|
||
err.name = name; | ||
err.originalStack = err.stack + errorTrace; | ||
tempStack = err.stack + errorTrace; | ||
err.failedPath = failedPath; | ||
|
||
// only print the part of the stack trace that refers to the user code: | ||
var splitStack = tempStack.split('\n'); | ||
splitStack = splitStack.filter(function(ln) { | ||
return !ln.match(/(p5.|native code|globalInit)/g); | ||
}); | ||
err.stack = splitStack.join('\n'); | ||
|
||
return err; | ||
}; | ||
|
||
return CustomError | ||
}); |
This file contains 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