Sha256: 4a379474cd8441bc5bcad28f0137b3a3a2a5569f1ebba14c7335cfdf656dc06a

Contents?: true

Size: 1014 Bytes

Versions: 3

Compression:

Stored size: 1014 Bytes

Contents

JLog.getExceptionMessage = function(ex) {
  if (ex.message) {
    return ex.message;
  } else if (ex.description) {
    return ex.description;
  } else {
    return String(ex);
  }
};

// Gets the portion of the URL after the last slash
JLog.getUrlFileName = function (url) {
  var lastSlashIndex = Math.max(url.lastIndexOf("/"), url.lastIndexOf("\\"));
  return url.substr(lastSlashIndex + 1);
};

JLog.showStackTraces = true;
JLog.newLine = "\n";

// Returns a nicely formatted representation of an error
JLog.getExceptionStringRep = function (ex) {
  if (ex) {
    var exStr = "Exception: " + JLog.getExceptionMessage(ex);
    try {
      if (ex.lineNumber) {
        exStr += " on line number " + ex.lineNumber;
      }
      if (ex.fileName) {
        exStr += " in file " + JLog.getUrlFileName(ex.fileName);
      }
    } catch (localEx) {
    }
    if (JLog.showStackTraces && ex.stack) {
      exStr += JLog.newLine + "Stack trace:" + JLog.newLine + ex.stack;
    }
    return exStr;
  }
  return null;
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jlog-rails-0.2.3 src/helpers.js
jlog-rails-0.2.2 vendor/assets/javascripts/helpers.js
jlog-rails-0.2.1 vendor/assets/javascripts/helpers.js