Skip to content

Commit

Permalink
debug created units
Browse files Browse the repository at this point in the history
  • Loading branch information
UmamiAppearance committed Jan 12, 2023
1 parent db7c85e commit f6b40cd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,29 @@ class ImportManager {
// ________________________ //
// global debugging methods //


/**
* Debug statements created by IM.
* @param {string} code - Code Snippet String.
* @param {Object} [target] - Target Unit Object.
* @param {string} [type] - Target type.
* @param {string} [mode] - Insert position or attach mode.
*/
logCreations(code, target, type, mode) {
let msg = {
addCode: code
};
if (target) {
msg.mode = mode;
msg.targetType = target.type;
msg.targetUnit = target.methods.log(false);
} else if (type) {
msg.insert = mode;
msg.targetType = type;
}
throw new DebuggingError(msg);
}


/**
* Debugging method to stop the building process
Expand Down
7 changes: 5 additions & 2 deletions src/unit-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,13 @@ export default class ImportManagerUnitMethods {
* Debugging method to stop the building process
* and list this unit properties.
*/
log() {
log(error=true) {
const unit = { ...this.unit };
delete unit.methods;
unit.code = [ unit.code.toString() ];
throw new DebuggingError(unit);
if (error) {
throw new DebuggingError(unit);
}
return unit;
}
}

0 comments on commit f6b40cd

Please sign in to comment.