From b9f1bb5e53c33f20880cab2e05c32c51a015931e Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 30 Jul 2024 15:45:26 -0500 Subject: [PATCH] more error handling --- .dist/snowflake.js | 8 +++++++- webpage/snowflake.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.dist/snowflake.js b/.dist/snowflake.js index 6b7dd35..a5b90dc 100644 --- a/.dist/snowflake.js +++ b/.dist/snowflake.js @@ -75,7 +75,13 @@ class SnowFlake { } } getUnixTime() { - return Number((BigInt(this.id) >> 22n) + 1420070400000n); + try { + return Number((BigInt(this.id) >> 22n) + 1420070400000n); + } + catch { + console.error(`The ID is corrupted, it's ${this.id} when it should be some number.`); + return 0; + } } toString() { return this.id; diff --git a/webpage/snowflake.ts b/webpage/snowflake.ts index f3042a0..81480ac 100644 --- a/webpage/snowflake.ts +++ b/webpage/snowflake.ts @@ -73,7 +73,12 @@ class SnowFlake{ } } getUnixTime():number{ - return Number((BigInt(this.id)>>22n)+1420070400000n); + try{ + return Number((BigInt(this.id)>>22n)+1420070400000n); + }catch{ + console.error(`The ID is corrupted, it's ${this.id} when it should be some number.`) + return 0; + } } toString(){ return this.id;