UNPKG

2.13 kBJavaScriptView Raw
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15'use strict';
16
17const BaseException = require('./baseexception');
18
19/**
20 * Exception throws when a Concerto file is semantically invalid
21 * @extends BaseException
22 * @see {@link BaseException}
23 * @class
24 * @memberof module:concerto-core
25 */
26class BaseFileException extends BaseException {
27 /**
28 * Create an BaseFileException
29 * @param {string} message - the message for the exception
30 * @param {string} fileLocation - the optional file location associated with the exception
31 * @param {string} fullMessage - the optional full message text
32 * @param {string} [fileName] - the file name
33 * @param {string} [component] - the component which throws this error
34 */
35 constructor(message, fileLocation, fullMessage, fileName, component) {
36 super(fullMessage ? fullMessage : message, component);
37 this.fileLocation = fileLocation;
38 this.shortMessage = message;
39 this.fileName = fileName;
40 }
41
42 /**
43 * Returns the file location associated with the exception or null
44 * @return {string} the optional location associated with the exception
45 */
46 getFileLocation() {
47 return this.fileLocation;
48 }
49
50 /**
51 * Returns the error message without the location of the error
52 * @returns {string} the error message
53 */
54 getShortMessage() {
55 return this.shortMessage;
56 }
57
58 /**
59 * Returns the fileName for the error
60 * @returns {string} the file name or null
61 */
62 getFileName() {
63 return this.fileName;
64 }
65}
66
67module.exports = BaseFileException;