more error handling
This commit is contained in:
@@ -75,8 +75,14 @@ class SnowFlake {
|
||||
}
|
||||
}
|
||||
getUnixTime() {
|
||||
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;
|
||||
}
|
||||
|
@@ -73,7 +73,12 @@ class SnowFlake<x extends WeakKey>{
|
||||
}
|
||||
}
|
||||
getUnixTime():number{
|
||||
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;
|
||||
|
Reference in New Issue
Block a user