Skip to content

Commit

Permalink
(feat) update dependencies and add a filename to the BaseFileException (
Browse files Browse the repository at this point in the history
#41)

* (feat) update dependencies and add a filename to the BaseFileException

Signed-off-by: Dan Selman <danscode@selman.org>

* (fix) merge issues

Signed-off-by: Dan Selman <danscode@selman.org>
  • Loading branch information
dselman committed Jun 25, 2019
1 parent bde4353 commit 533b80f
Show file tree
Hide file tree
Showing 8 changed files with 1,445 additions and 1,090 deletions.
16 changes: 13 additions & 3 deletions lib/basefileexception.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ const BaseException = require('./baseexception');
class BaseFileException extends BaseException {

/**
* Create an IllegalModelException
* Create an BaseFileException
* @param {string} message - the message for the exception
* @param {string} fileLocation - the optional file location associated with the exception
* @param {string} fullMessage - the optional full message text
* @param {string} component - the optional component which throws this error
* @param {string} fileName - the optional file name
* @param {string} component - the optional component which throws this error
*/
constructor(message, fileLocation, fullMessage, component) {
constructor(message, fileLocation, fullMessage, fileName, component) {
super(fullMessage ? fullMessage : message, component);
this.fileLocation = fileLocation;
this.shortMessage = message;
this.fileName = fileName;
}

/**
Expand All @@ -54,6 +56,14 @@ class BaseFileException extends BaseException {
getShortMessage() {
return this.shortMessage;
}

/**
* Returns the fileName for the error
* @returns {string} the file name or null
*/
getFileName() {
return this.fileName;
}
}

module.exports = BaseFileException;
3 changes: 2 additions & 1 deletion lib/codegen/parsejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const fs = require('fs-extra');
const klaw = require('klaw');
const path = require('path');
const program = require('commander');
const PlantUMLGenerator = require('./fromjs/plantumlgenerator');
Expand Down Expand Up @@ -48,7 +49,7 @@ function processFile(file, fileProcessor) {
*/
function processDirectory(path, fileProcessor) {
let items = [];
fs.walk(path)
klaw(path)
.on('readable', function (item) {
while ((item = this.read())) {
if (item.stats.isFile()) {
Expand Down
4 changes: 3 additions & 1 deletion lib/introspect/illegalmodelexception.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class IllegalModelException extends BaseFileException {
constructor(message, modelFile, fileLocation, component) {

let messageSuffix = '';
let fileName = null;
if(modelFile && modelFile.getName()) {
fileName = modelFile.getName();
messageSuffix = 'File \'' + modelFile.getName() + '\': ' ;
}

Expand All @@ -53,7 +55,7 @@ class IllegalModelException extends BaseFileException {
// First character to be uppercase
messageSuffix = messageSuffix.charAt(0).toUpperCase() + messageSuffix.slice(1);

super(message, fileLocation, message + ' ' + messageSuffix, component);
super(message, fileLocation, message + ' ' + messageSuffix, fileName, component);
this.modelFile = modelFile;
}

Expand Down
5 changes: 2 additions & 3 deletions lib/introspect/parseexception.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ParseException extends BaseFileException {
}

// The parser does not give us back the end location of an invalid token.
// Making the end column equal to the end column makes use of
// Making the end column equal to the start column makes use of
// vscodes default behaviour of selecting an entire word
if (fileLocation) {
if (fileLocation.end && fileLocation.start) {
Expand All @@ -65,9 +65,8 @@ class ParseException extends BaseFileException {
}

fullMessage += suffix;
super(message, fileLocation, fullMessage, component);
super(message, fileLocation, fullMessage, fileName, component);
}

}

module.exports = ParseException;
Loading

0 comments on commit 533b80f

Please sign in to comment.