Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

Commit

Permalink
Added re-throwing of errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
csd713 authored and armenzg committed Jul 17, 2018
1 parent dc90315 commit a5f48df
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/diffLine.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const DiffLine = ({ change, fileDiffs, id }) => {
rowClass = 'nolinechange';
}
} catch (e) {
console.log(e);
rowClass = 'miss';
throw e;
}
}
newLineNumber = c.ln;
Expand Down
2 changes: 1 addition & 1 deletion src/containers/diffViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export default class DiffViewerContainer extends Component {
}
this.setState({ appError, coverage });
} catch (error) {
console.error(error);
this.setState({
appError: 'There was an error fetching the code coverage data.',
});
throw error;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/containers/fileViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class FileViewerContainer extends Component {
});
} catch (error) {
this.setState({ appErr: `${error.name}: ${error.message}` });
throw error;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/containers/summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export default class SummaryContainer extends Component {
pollingEnabled: summary.pending > 0,
});
} catch (error) {
console.error(error);
this.setState({
changesets: {},
changesetsCoverage: {},
pollingEnabled: false,
errorMessage: 'We have failed to fetch coverage data.',
});
throw error;
}
}

Expand All @@ -78,6 +78,7 @@ export default class SummaryContainer extends Component {
this.setState({ changesetsCoverage, pollingEnabled });
} catch (e) {
this.setState({ pollingEnabled: false });
throw e;
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/utils/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const fileRevisionCoverageSummary = (coverage) => {
s.numUncovLines = s.uncoveredLines.length;
s.numTotalLines = s.numCovLines + s.numUncovLines;
s.percentage = (s.numCovLines !== 0 ||
s.numUncovLines !== 0) ? ((s.numCovLines / s.numTotalLines) * 100) : undefined;
s.numUncovLines !== 0) ? ((s.numCovLines / s.numTotalLines) * 100) : undefined;
return s;
};

Expand Down Expand Up @@ -245,11 +245,10 @@ export const fileRevisionWithActiveData = async (revision, path, repoPath) => {
format: 'list',
});
if (res.status !== 200) {
throw new Error();
throw new Error(`HTTP response ${res.status}`);
}
return res.json();
} catch (e) {
console.error(`Failed to fetch data for revision: ${revision}, path: ${path}\n${e}`);
throw e;
throw new Error(`Failed to fetch data for revision: ${revision}, path: ${path}\n${e}`);
}
};
5 changes: 2 additions & 3 deletions src/utils/hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ export const rawFile = async (node, filePath, repoName = REPO_NAME) => {
try {
const res = await getRawFile(node, filePath, repoName);
if (res.status !== 200) {
throw new Error();
throw new Error(`HTTP response ${res.status}`);
}
return (await res.text()).split('\n');
} catch (e) {
console.error(`Failed to fetch source for revision: ${node}, filePath: ${filePath}\n${e}`);
throw new Error('Failed to get source code from hg');
throw new Error(`Failed to fetch source for revision: ${node}, filePath: ${filePath}\n${e}`);
}
};

Expand Down

0 comments on commit a5f48df

Please sign in to comment.