aboutsummaryrefslogtreecommitdiff
path: root/src/js/shared.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/shared.ts')
-rw-r--r--src/js/shared.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/js/shared.ts b/src/js/shared.ts
new file mode 100644
index 000000000..1e3da7d51
--- /dev/null
+++ b/src/js/shared.ts
@@ -0,0 +1,30 @@
+export class NotImplementedError extends Error {
+ code: string;
+ constructor(feature: string, issue?: number) {
+ super(
+ feature +
+ " is not yet implemented in Bun." +
+ (issue ? " Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/" + issue : ""),
+ );
+ this.name = "NotImplementedError";
+ this.code = "ERR_NOT_IMPLEMENTED";
+
+ // in the definition so that it isn't bundled unless used
+ hideFromStack(NotImplementedError);
+ }
+}
+
+export function throwNotImplemented(feature: string, issue?: number): never {
+ // in the definition so that it isn't bundled unless used
+ hideFromStack(throwNotImplemented);
+
+ throw new NotImplementedError(feature, issue);
+}
+
+export function hideFromStack(...fns) {
+ for (const fn of fns) {
+ Object.defineProperty(fn, "name", {
+ value: "::bunternal::",
+ });
+ }
+}