UNPKG

1.8 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');
18const Globalize = require('./globalize');
19
20/**
21 * Error thrown when a Concerto type does not exist.
22 * @extends BaseException
23 * @see see {@link BaseException}
24 * @class
25 * @memberof module:concerto-core
26 * @private
27 */
28class TypeNotFoundException extends BaseException {
29 /**
30 * Constructor. If the optional 'message' argument is not supplied, it will be set to a default value that
31 * includes the type name.
32 * @param {String} typeName - fully qualified type name.
33 * @param {String} [message] - error message.
34 * @param {String} component - the optional component which throws this error
35 */
36 constructor(typeName, message, component) {
37 if (!message) {
38 const formatter = Globalize.messageFormatter('typenotfounderror-defaultmessage');
39 message = formatter({
40 typeName: typeName
41 });
42 }
43
44 super(message, component);
45 this.typeName = typeName;
46 }
47
48 /**
49 * Get the name of the type that was not found.
50 * @returns {string} fully qualified type name.
51 */
52 getTypeName() {
53 return this.typeName;
54 }
55
56}
57
58module.exports = TypeNotFoundException;