Added custom error class
This commit is contained in:
7
src/utils/Classes.ts
Normal file
7
src/utils/Classes.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export class MissingEnvVarsError extends Error {
|
||||||
|
constructor(value: string) {
|
||||||
|
super("Missing environment variables")
|
||||||
|
|
||||||
|
this.message = value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { color } from "utils/functions/colors.js"
|
|||||||
import { Player } from "discord-player"
|
import { Player } from "discord-player"
|
||||||
import { YoutubeiExtractor } from "discord-player-youtubei"
|
import { YoutubeiExtractor } from "discord-player-youtubei"
|
||||||
import { Sequelize } from "sequelize"
|
import { Sequelize } from "sequelize"
|
||||||
|
import { MissingEnvVarsError } from "./Classes.js"
|
||||||
import loadAllEvents from "./Events/loadevents.js"
|
import loadAllEvents from "./Events/loadevents.js"
|
||||||
|
|
||||||
const client = new Client()
|
const client = new Client()
|
||||||
@@ -61,14 +62,14 @@ class Illegitimate {
|
|||||||
|
|
||||||
if (process.env.NODE_ENV === "dev") {
|
if (process.env.NODE_ENV === "dev") {
|
||||||
for (const [key, value] of Object.entries(devValues)) {
|
for (const [key, value] of Object.entries(devValues)) {
|
||||||
if (!value) throw new Error(`No ${key} specified`)
|
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
|
||||||
}
|
}
|
||||||
for (const [key, value] of Object.entries(prodValues)) {
|
for (const [key, value] of Object.entries(prodValues)) {
|
||||||
if (!value) throw new Error(`No ${key} specified`)
|
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const [key, value] of Object.entries(prodValues)) {
|
for (const [key, value] of Object.entries(prodValues)) {
|
||||||
if (!value) throw new Error(`No ${key} specified`)
|
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user