Skip to content

Commit

Permalink
task: remove extra error class
Browse files Browse the repository at this point in the history
  • Loading branch information
rosmcmahon committed May 4, 2024
1 parent bcb5011 commit 96cd5bb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 2 additions & 8 deletions src/common/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as B64js from "base64-js";

class UtilsError extends Error {
constructor(...args: ConstructorParameters<typeof Error>) {
super(...args);
this.name = "UtilsError";
}
}

export type Base64UrlString = string;

Expand Down Expand Up @@ -69,7 +63,7 @@ export function b64UrlEncode(b64UrlString: string): string {
.replace(/\//g, "_")
.replace(/\=/g, "");
} catch (error) {
throw new UtilsError("Failed to encode string", { cause: error });
throw new Error("Failed to encode string", { cause: error });
}
}

Expand All @@ -82,6 +76,6 @@ export function b64UrlDecode(b64UrlString: string): string {
: (padding = 4 - (b64UrlString.length % 4));
return b64UrlString.concat("=".repeat(padding));
} catch (error) {
throw new UtilsError("Failed to decode string", { cause: error });
throw new Error("Failed to decode string", { cause: error });
}
}
2 changes: 0 additions & 2 deletions test/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("Common Utils", function () {
} catch (error) {
expect(error).to.have.property("message");
expect(error).to.have.property("cause");
expect((error as Error).name).to.be.string("UtilsError");
expect((error as Error).message).to.be.string(testCase.message);
}
});
Expand All @@ -29,7 +28,6 @@ describe("Common Utils", function () {
} catch (error) {
expect(error).to.have.property("message");
expect(error).to.have.property("cause");
expect((error as Error).name).to.be.string("UtilsError");
expect((error as Error).message).to.be.string(testCase.message);
}
});
Expand Down

0 comments on commit 96cd5bb

Please sign in to comment.