Skip to content

Commit

Permalink
Merge pull request #9 from willmanduffy/centralize-errors-folder
Browse files Browse the repository at this point in the history
Centralize errors folder
  • Loading branch information
willmanduffy authored Dec 1, 2024
2 parents 482ebae + f2e132a commit 070021c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/api-wrappers/bluesky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { BlueSky } from "./bluesky";
import { AtpAgent, ComAtprotoServerCreateSession } from "@atproto/api";
import { mockEnv } from "../../tests/fixtures/env";
import { RateLimitError } from "../errors/rate-limit-error";
import { RateLimitError } from "../errors";

type CreateSessionResponse = ComAtprotoServerCreateSession.Response;

Expand Down
2 changes: 1 addition & 1 deletion src/api-wrappers/bluesky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@atproto/api";

import { Env } from "../types";
import { RateLimitError } from "../errors/rate-limit-error";
import { RateLimitError } from "../errors";
import { BlueskyRateLimitExceededError } from "../types/bluesky";

const SESSION_KEY = "session";
Expand Down
2 changes: 2 additions & 0 deletions src/errors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { NoEnabledServicesError } from "./no-enabled-services-error";
export { RateLimitError } from "./rate-limit-error";
5 changes: 5 additions & 0 deletions src/errors/no-enabled-services-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class NoEnabledServicesError extends Error {
constructor() {
super("You must enable at least one service to fetch the latest track.");
}
}
7 changes: 1 addition & 6 deletions src/services/latest-track-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { LastFM } from "../api-wrappers/lastfm";
import { NoEnabledServicesError } from "../errors";
import { Env } from "../types";
import { NormalizedTrack } from "../types/track";

type EnabledServices = "lastfm";

class NoEnabledServicesError extends Error {
constructor() {
super("You must enable at least one service to fetch the latest track.");
}
}

export class LatestTrackFetcher {
private env: Env;
private lastfm: LastFM;
Expand Down

0 comments on commit 070021c

Please sign in to comment.