Skip to content

Commit

Permalink
try - catch the whole func
Browse files Browse the repository at this point in the history
  • Loading branch information
ivojawer committed Jun 12, 2024
1 parent d4d2bc2 commit e2a0e72
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export function getTarget(environment: Environment, filter: string | undefined,
let possibleTargets: Test[]
try {
possibleTargets = getBaseNode(environment, filter, options).descendants.filter(getTestFilter(filter, options))
const onlyTarget = possibleTargets.find((test: Test) => test.isOnly)
const testMatches = (filter: string) => (test: Test) => !filter || sanitize(test.fullyQualifiedName)!.includes(filter)
const filterTest = sanitize(filter) ?? ''
return onlyTarget ? [onlyTarget] : possibleTargets.filter(testMatches(filterTest))
} catch(e: any){
if(e instanceof TestSearchMissError){
logger.error(red(bold(e.message)))
return []
}
throw e
}
const onlyTarget = possibleTargets.find((test: Test) => test.isOnly)
const testMatches = (filter: string) => (test: Test) => !filter || sanitize(test.fullyQualifiedName)!.includes(filter)
const filterTest = sanitize(filter) ?? ''
return onlyTarget ? [onlyTarget] : possibleTargets.filter(testMatches(filterTest))
}

function getBaseNode(environment: Environment, filter: string | undefined, options: Options): Environment | Package | Describe {
Expand Down

0 comments on commit e2a0e72

Please sign in to comment.