-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(error): adding type to error in string validator in introspect #773
Changes from all commits
f4ab97b
3b6180a
6fce3db
18bd20f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ declare class TypeNotFoundException extends BaseException { | |
* @param {string} typeName - fully qualified type name. | ||
* @param {string|undefined} message - error message. | ||
* @param {string} component - the optional component which throws this error | ||
* @param {string} errorType - the error code related to the error | ||
*/ | ||
constructor(typeName: string, message: string | undefined, component: string); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the main I still see constructor on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this is actually auto generated after I run build command |
||
constructor(typeName: string, message: string | undefined, component: string, errorType?: string); | ||
typeName: string; | ||
/** | ||
* Get the name of the type that was not found. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,10 @@ | |
|
||
'use strict'; | ||
|
||
|
||
|
||
const packageJson = require('../package.json'); | ||
const ErrorCodes = require('./errorcodes'); | ||
|
||
/** | ||
* A base class for all Concerto exceptions | ||
|
@@ -27,12 +30,14 @@ class BaseException extends Error { | |
* Create the BaseException. | ||
* @param {string} message - The exception message. | ||
* @param {string} component - The optional component which throws this error. | ||
* @param {string} errorType - The optional error code regarding the error | ||
*/ | ||
constructor(message, component) { | ||
constructor(message, component, errorType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a errortype parameter which is optional and provides the errorcode related to the error |
||
super(message); | ||
this.component = component || packageJson.name; | ||
this.name = this.constructor.name; | ||
this.message = message; | ||
this.errorType = errorType || ErrorCodes.DEFAULT_BASE_EXCEPTION; | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error codes are defined in this file which can be used to implement different errors when ever needed |
||
//default base exception | ||
const DEFAULT_BASE_EXCEPTION = 'DefaultBaseException'; | ||
//default validator exception which is being used when there is no specified validator exception in introspect | ||
const DEFAULT_VALIDATOR_EXCEPTION = 'DefaultValidatorException'; | ||
// exception code for regex validator format error | ||
const REGEX_VALIDATOR_EXCEPTION = 'RegexValidatorException'; | ||
// base exception for Type not found | ||
const TYPE_NOT_FOUND_EXCEPTION = 'TypeNotFoundException'; | ||
|
||
module.exports = {DEFAULT_BASE_EXCEPTION, DEFAULT_VALIDATOR_EXCEPTION, REGEX_VALIDATOR_EXCEPTION, TYPE_NOT_FOUND_EXCEPTION}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const DEFAULT_BASE_EXCEPTION: "DefaultBaseException"; | ||
export const DEFAULT_VALIDATOR_EXCEPTION: "DefaultValidatorException"; | ||
export const REGEX_VALIDATOR_EXCEPTION: "RegexValidatorException"; | ||
export const TYPE_NOT_FOUND_EXCEPTION: "TypeNotFoundException"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I have used error codes as constants instead of inline strings for consistency