Skip to content

Commit

Permalink
Move file
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent 7ba6e65 commit 943fe00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
21 changes: 21 additions & 0 deletions src/run/measure/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import filterObj from 'filter-obj'

import { getCombinationName } from '../../combination/name.js'

// When an error happens while a measuring a specific combination, display its
// dimensions in the error message
export const prependMeasureError = function (error, combination) {
const combinationPrefix = getCombinationPrefix(combination)
error.message = `In ${combinationPrefix}:\n${error.message}`
}

const getCombinationPrefix = function (combination) {
const dimensions = filterObj(combination.dimensions, shouldKeepDimension)
return getCombinationName({ ...combination, dimensions })
}

// Some dimensions are always the same during a given run, i.e. are not useful
// in error messages
const shouldKeepDimension = function (dimension) {
return !dimension.startsWith('system')
}
24 changes: 2 additions & 22 deletions src/run/measure/single.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import filterObj from 'filter-obj'

import { getCombinationName } from '../../combination/name.js'
import { startLogs, stopLogs, hasLogs } from '../logs/create.js'
import { addErrorTaskLogs } from '../logs/error.js'
import { startLogsStream, stopLogsStream } from '../logs/stream.js'
Expand All @@ -15,6 +12,7 @@ import {
} from '../process/runner.js'
import { throwIfStopped } from '../stop/error.js'

import { prependMeasureError } from './error.js'
import { runEvents } from './events.js'

// Measure a single combination
Expand Down Expand Up @@ -99,25 +97,7 @@ const handleErrorsAndMeasure = async function ({ onTaskExit, ...args }) {
try {
return await Promise.race([onTaskExit, runEvents(args)])
} catch (error) {
prependCombinationPrefix(error, args.combination)
prependMeasureError(error, args.combination)
throw error
}
}

// When an error happens while a measuring a specific combination, display its
// dimensions in the error message
const prependCombinationPrefix = function (error, combination) {
const combinationPrefix = getCombinationPrefix(combination)
error.message = `In ${combinationPrefix}:\n${error.message}`
}

const getCombinationPrefix = function (combination) {
const dimensions = filterObj(combination.dimensions, shouldKeepDimension)
return getCombinationName({ ...combination, dimensions })
}

// Some dimensions are always the same during a given run, i.e. are not useful
// in error messages
const shouldKeepDimension = function (dimension) {
return !dimension.startsWith('system')
}

0 comments on commit 943fe00

Please sign in to comment.