Skip to content

Commit

Permalink
fix: 404 error returned for unknown trees and countries
Browse files Browse the repository at this point in the history
  • Loading branch information
kparikh9 committed Jan 24, 2022
1 parent 9492aee commit c40f0e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions __tests__/e2e/trees.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ describe("trees", () => {
});
})

it("Unknown tree", async () => {
const response = await supertest(app).get("/trees/1");
expect(response.status).toBe(404);
})

it("trees?limit=1&offset=0", async () => {
const response = await supertest(app).get("/trees?limit=1&offset=0");
expect(response.status).toBe(200);
Expand Down
1 change: 1 addition & 0 deletions server/utils/HttpError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class HttpError extends Error {

constructor(code: number, message: string, toRollback: boolean = true) {
super(message)
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
this.code = code
// set rollback flag, so the transaction of db would rollback when catch this error
// set default to true
Expand Down

0 comments on commit c40f0e2

Please sign in to comment.