Skip to content

Commit

Permalink
Set fake 404 status code when throwing NotFoundError for missing link
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Apr 3, 2023
1 parent a7040f0 commit a850f4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions endpoints/Endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpMethod, HttpHeader, HttpClient } from "../http";
import { HttpMethod, HttpHeader, HttpStatusCode, HttpClient } from "../http";
import { Serializer } from "../serializers";
import { ErrorHandler, NotFoundError } from "../errors";
import { LinkExtractor, Link } from "../links";
Expand Down Expand Up @@ -188,7 +188,7 @@ export class Endpoint {
const links = this.getLinks(rel);

if (links.length === 0)
throw new NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`, 0);
throw new NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`, HttpStatusCode.NotFound);

return links[0].uri;
}
Expand All @@ -214,7 +214,7 @@ export class Endpoint {
?? this.defaultLinkTemplates.get(rel);

if (!template)
throw new NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`, 0);
throw new NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`, HttpStatusCode.NotFound);

return template;
}
Expand Down

0 comments on commit a850f4e

Please sign in to comment.