Skip to content

Commit

Permalink
factor-out-errors (#17)
Browse files Browse the repository at this point in the history
factor out NotFoundError

Move from feed.ts to error.ts.
  • Loading branch information
wydengyre authored Jan 27, 2024
1 parent 4da8b27 commit bafc27c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 6 additions & 0 deletions lib/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class NotFoundError extends Error {
constructor(url: URL) {
super(`Not found: ${url}`);
this.name = "NotFoundError";
}
}
3 changes: 2 additions & 1 deletion lib/feed-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createResponse } from "itty-router";
import { NotFoundError, convertFeed } from "./feed.js";
import { NotFoundError } from "./error.js";
import { convertFeed } from "./feed.js";
import { Logger } from "./logger.js";

type Config = {
Expand Down
2 changes: 1 addition & 1 deletion lib/feed.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { error, json } from "itty-router";
import { NotFoundError } from "./error.js";
import {
Convertor,
ConvertorConf,
FeedConf,
FeedFetcher,
FetcherConf,
NotFoundError,
convertFeed,
} from "./feed.js";
import { Fetcher as MediaFetcher } from "./media.js";
Expand Down
8 changes: 1 addition & 7 deletions lib/feed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PromisePool } from "@supercharge/promise-pool";
import { z } from "zod";
import { Podcast } from "../build/podcast/index.js";
import { NotFoundError } from "./error.js";
import { Fetcher as MediaFetcher } from "./media.js";

const cardSchema = z.object({
Expand Down Expand Up @@ -77,13 +78,6 @@ export class FeedFetcher {
}
}

export class NotFoundError extends Error {
constructor(url: URL) {
super(`Not found: ${url}`);
this.name = "NotFoundError";
}
}

export type ConvertorConf = {
raiBaseUrl: URL;
poolSize: number;
Expand Down

0 comments on commit bafc27c

Please sign in to comment.