in src/core/runner.ts [382:419]
async _runJourney(journey: Journey, options: RunOptions) {
this.#currentJourney = journey;
log(`Runner: start journey (${journey.name})`);
let result: JourneyResult = {};
const hookArgs = {
env: options.environment,
params: options.params,
info: this,
};
try {
await this.#startJourney(journey, options);
await this.#runBeforeHook(journey, hookArgs);
const stepResults = await this.#runSteps(journey, options);
journey.status = 'succeeded';
// Mark journey as failed if any one of the step fails
for (const step of journey.steps) {
if (step.status === 'failed') {
journey.status = step.status;
journey.error = step.error;
}
}
result.stepsresults = stepResults;
} catch (e) {
journey.status = 'failed';
journey.error = e;
} finally {
journey.duration = monotonicTimeInSeconds() - journey._startTime;
// Run after hook on journey failure and capture the uncaught error as
// journey error, hook is purposely run before to capture errors during reporting
await this.#runAfterHook(journey, hookArgs).catch(e => {
journey.status = 'failed';
journey.error = e;
});
result = await this.#endJourney(journey, result, options);
}
log(`Runner: end journey (${journey.name})`);
return result;
}