Skip to content

Commit

Permalink
fix: uses WrappedError constructor when an error overwrite is intended
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 30, 2019
1 parent 6596a1e commit f72b5a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/core/paths/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import { IPaths } from '../types';
import getPaths from './paths';
import { wrap } from '~/utils/errors';
import { WrappedError } from '~/utils/errors';
import { absolute } from '~/utils/file';

/**
Expand Down Expand Up @@ -33,9 +33,10 @@ export async function getRootPaths(directories: {
return await getPaths({ directory }, Boolean(root));
} catch (err) {
if (!root) return null;
throw wrap.ensure(err, {
allow: [],
message: `root scope couldn't be retrieved: ${root}`
});
throw new WrappedError(
`root scope couldn't be retrieved: ${root}`,
null,
err
);
}
}
11 changes: 6 additions & 5 deletions src/public/exec/parallel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import core from '~/core';
import { IExecOptions, IOfType } from '~/types';
import logger from '~/utils/logger';
import { wrap } from '~/utils/errors';
import { WrappedError } from '~/utils/errors';
import expose from '~/utils/expose';
import join from 'command-join';

Expand Down Expand Up @@ -67,10 +67,11 @@ const parallel: IParallel = (() => {
options
);
} catch (e) {
const err = wrap.ensure(e, {
allow: [],
message: 'Parallel commands execution failed'
});
const err = new WrappedError(
'Parallel commands execution failed',
null,
e
);
if (options.silent) logger.error(err.message);
else throw err;
}
Expand Down

0 comments on commit f72b5a7

Please sign in to comment.