Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Redirect to local project page
redirect: details.redirecter(params.target.repoRef),
// local SDM uses this to print instructions
generatedRepositoryUrl: params.target.repoRef.url,
} as any;
} catch (err) {
if (err instanceof CommandListenerExecutionInterruptError) {
// We're continuing
return Success as any;
}
await ctx.messageClient.respond(
slackErrorMessage(
`Create Project`,
`Project creation for ${bold(`${params.target.repoRef.owner}/${params.target.repoRef.repo}`)} failed:
${codeBlock(err.message)}`,
ctx));
}
}
{
// reuse the other parameters, but set the dryRun flag to false and pin to one repo
...params,
"dry-run": false,
"dry-run.msgId": msgId,
"targets.sha": params.targets.sha,
"targets.owner": id.owner,
"targets.repo": id.repo,
}),
],
};
await ctx.messageClient.respond(
slackInfoMessage(
`Code Transform (dry run)`,
`Code transform ${italic(codeTransformName)} would make the following changes to ${bold(slug(id))}:
${codeBlock(diff)}
`, applyAction), { id: msgId });
}
logger.error(`Error diffing project: %s`, err.message);
diff = `Error obtaining \`git diff\`:
${codeBlock(err.message)}`;
}
await sendDryRunSummaryMessage(editorName, id, diff, params, context);
return { target: project, edited: false, success: true };
} else {
await sendSuccessMessage(editorName, id, params, context);
}
return editResult;
} catch (err) {
await context.messageClient.respond(
slackErrorMessage(
`Code Transform${isDryRun(params) ? " (dry run)" : ""}`,
`Code transform ${italic(editorName)} failed while changing ${bold(slug(id))}:\n\n${codeBlock(err.message)}`,
context), { id: params[DryRunMsgIdParameter.name] });
logger.warn("Code Transform error acting on %j: %s", project.id, err);
return { target: project, edited: false, success: false };
}
};
}
return ci.addressChannels(
slackErrorMessage(
`Code Transform`,
`Code transform ${italic(ci.commandName)} failed${!!error.message ? ":\n\n" + codeBlock(error.message) : "."}`,
ci.context,
),
);
} else {
logger.debug("No react function to react to result of code transformation '%s'", ctr.name);
}
}
} catch (e) {
return ci.addressChannels(
slackErrorMessage(
`Code Transform`,
`Code transform ${italic(ci.commandName)} failed${!!e.message ? ":\n\n" + codeBlock(e.message) : "."}`,
ci.context,
),
);
}
},
};
return async l => {
try {
progressLog.write(`Running review listener ${l.name}...`);
const result = (await l.listener(rli)) || PushImpactResponse.proceed;
progressLog.write(`Review listener + ${l.name} result: ` + result);
return result;
} catch (err) {
logger.error("Review listener %s failed. Stack: %s", l.name, err.stack);
progressLog.write(`Review listener ${l.name} error: ` + err.message);
progressLog.write(`Failing autoinspect goal because a review listener failed.`);
await rli.addressChannels(
slackErrorMessage(
"Review Listener",
`Review listener ${italic(l.name)} failed${err.message ? `:
${codeBlock(err.message)}` : ""}`,
rli.context));
return PushImpactResponse.failGoals;
}
};
}
} else {
const project = await repoLoader(ids[0]);
const result = await action(project, ci.parameters);
if (!!cir.onInspectionResults) {
await cir.onInspectionResults([result], ci);
} else {
logger.debug("No react function to react to results of code inspection '%s'", cir.name);
}
}
} catch (e) {
return ci.addressChannels(
slackErrorMessage(
`Code Inspection`,
`Code Inspection ${italic(ci.commandName)} failed:
${codeBlock(e.message)}`,
ci.context,
),
);
}
},
};