Skip to content

Commit

Permalink
Removed addonName from fileName
Browse files Browse the repository at this point in the history
The addonName was in the stack trace but also in fileName, which breaks the ability to create a direct link to the source code.
  • Loading branch information
RomainVialard authored Apr 23, 2018
1 parent ce5b591 commit f5fcd05
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/ErrorHandler.gs.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,13 @@ function logError(error, additionalParams, options) {
}
log.message = message;

// allow to use a global variable instead of passing the addonName in each call
// noinspection JSUnresolvedVariable
var addonName = additionalParams && additionalParams.addonName || ErrorHandler_._this['SCRIPT_PROJECT_TITLE'] || '';

// Manage error Stack
if (error.lineNumber && error.fileName && error.stack) {
if (addonName) error.fileName = error.fileName.replace(" (" + addonName + ")", "");
var directLink = "https://script.google.com/macros/d/";
directLink+= ScriptApp.getScriptId() + "/edit?f=" + error.fileName + "&s=" + error.lineNumber;
log.context.reportLocation = {
Expand All @@ -286,8 +291,6 @@ function logError(error, additionalParams, options) {
directLink: directLink
};

var addonName = additionalParams && additionalParams.addonName || undefined;

var res = ErrorHandler_._convertErrorStack(error.stack, addonName);
log.context.reportLocation.functionName = res.lastFunctionName;
log.message+= '\n '+ res.stack;
Expand Down Expand Up @@ -482,11 +485,7 @@ ErrorHandler_._this = this;
* lastFunctionName: string
* }} - formatted stack and last functionName executed
*/
ErrorHandler_._convertErrorStack = function (stack, addonName) {
// allow to use a global variable instead of passing the addonName in each call
// noinspection JSUnresolvedVariable
addonName = addonName || ErrorHandler_._this['SCRIPT_PROJECT_TITLE'] || '';

ErrorHandler_._convertErrorStack = function (stack, addonName) {
var formattedStack = [];
var lastFunctionName = '';
var res;
Expand Down

0 comments on commit f5fcd05

Please sign in to comment.