diff --git a/x-pack/plugins/case/server/common/error.ts b/x-pack/plugins/case/server/common/error.ts index 517aa246aa329..95b05fd612e60 100644 --- a/x-pack/plugins/case/server/common/error.ts +++ b/x-pack/plugins/case/server/common/error.ts @@ -52,7 +52,8 @@ export function isCaseError(error: unknown): error is CaseError { } /** - * Create a CaseError that wraps the original thrown error. This also logs the message that will be placed in the CaseError. + * Create a CaseError that wraps the original thrown error. This also logs the message that will be placed in the CaseError + * if the logger was defined. */ export function createCaseError({ message, @@ -61,11 +62,11 @@ export function createCaseError({ }: { message?: string; error?: Error; - logger: Logger; + logger?: Logger; }) { const logMessage: string | undefined = message ?? error?.toString(); if (logMessage !== undefined) { - logger.error(logMessage); + logger?.error(logMessage); } return new CaseError(message, error); diff --git a/x-pack/plugins/case/server/connectors/case/index.ts b/x-pack/plugins/case/server/connectors/case/index.ts index 2502565118182..8d5897517aa89 100644 --- a/x-pack/plugins/case/server/connectors/case/index.ts +++ b/x-pack/plugins/case/server/connectors/case/index.ts @@ -153,9 +153,18 @@ interface AttachmentAlerts { indices: string[]; rule: { id: string | null; name: string | null }; } + +/** + * Convert a connector style comment passed through the action plugin to the expected format for the add comment functionality. + * + * @param comment an object defining the comment to be attached to a case/sub case + * @param logger an optional logger to handle logging an error if parsing failed + * + * Note: This is exported so that the integration tests can use it. + */ export const transformConnectorComment = ( comment: CommentSchemaType, - logger: Logger + logger?: Logger ): CommentRequest => { if (isCommentGeneratedAlert(comment)) { try {