UNPKG

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