Skip to content

Commit

Permalink
Fixing type error
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Feb 19, 2021
1 parent a7d6fe5 commit 3b64e60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions x-pack/plugins/case/server/common/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion x-pack/plugins/case/server/connectors/case/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3b64e60

Please sign in to comment.