Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Remove redundant try-catch #171

Merged
merged 1 commit into from
Jan 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/routes/add-article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { termToString } from 'rdf-string';
import uniqueString from 'unique-string';
import url from 'url';
import { AppContext, AppMiddleware } from '../app';
import NotAnArticle from '../errors/not-an-article';
import { rdf, schema } from '../namespaces';
import Routes from './index';

Expand Down Expand Up @@ -44,15 +43,7 @@ export default (): AppMiddleware => (
request.dataset.delete(originalQuad).add(newQuad);
});

try {
await articles.set(newId, request.dataset);
} catch (error) {
if (error instanceof NotAnArticle) {
throw new createHttpError.BadRequest(error.message);
}

throw error;
}
await articles.set(newId, request.dataset);

response.status = constants.HTTP_STATUS_CREATED;
response.set('Location', url.resolve(request.origin, router.url(Routes.ArticleList)));
Expand Down