Extracting message data
We can extract data from the message and put it in appropriate fields.
private readonly ENTITY_NAME_REGEX = /(?<=type\s")\w+/;private extractMessageData(message: string) {
const entityName = message.match(this.ENTITY_NAME_REGEX)[0];
return { entityName };
}export const extractFromText = (text: string, regex: RegExp) =>
text.match(regex)[0];const entityName = extractFromText(message, this.ENTITY_NAME_REGEX);const { entityName } = this.extractMessageData(exception.message);const message = `${entityName} not found`;Last updated