Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Feb 19, 2018
1 parent 6894a32 commit 2fe9780
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions packages/jest-haste-map/src/crawlers/watchman.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ import H from '../constants';
const watchmanURL =
'https://facebook.github.io/watchman/docs/troubleshooting.html';

class WatchmanError extends Error {
constructor(error) {
super(
`Watchman error: ${error.message.trim()}. Make sure watchman ` +
`is running for this project. See ${watchmanURL}.`,
);
const stack = error.stack;
if (stack) {
this.stack = stack;
}
}
function WatchmanError(error: Error): Error {
error.message =
`Watchman error: ${error.message.trim()}. Make sure watchman ` +
`is running for this project. See ${watchmanURL}.`;
return error;
}

module.exports = async function watchmanCrawl(
Expand Down Expand Up @@ -131,13 +125,13 @@ module.exports = async function watchmanCrawl(
}
}
} catch (error) {
throw new WatchmanError(error);
throw WatchmanError(error);
} finally {
client.end();
}

if (clientError) {
throw new WatchmanError(clientError);
throw WatchmanError(clientError);
}
data.files = files;
return data;
Expand Down

0 comments on commit 2fe9780

Please sign in to comment.