isExplainedError
function in meocord/common Since 4.1.0
isExplainedError(error: unknown): booleanWhether MeoCord has already logged what went wrong and what to do about it.
Use it where a bot logs a startup failure, so an error MeoCord explained is not logged twice: an app
MeoCordFactory.create() refuses, such as two handlers for one command, or Discord refusing the bot token or a
privileged intent at login. The error is otherwise unchanged.
Parameters
| Name | Type | Description |
|---|---|---|
error | unknown | An error |
Returns
booleantrue when MeoCord explained the error.
Examples
// src/main.ts, as a generated app has it
declare const App: new () => object
const logger = new Logger()
async function bootstrap() {
const app = MeoCordFactory.create(App)
await app.start()
}
// An error MeoCord explained, such as an app it refuses or a token Discord refused, is already logged
bootstrap().catch(error => {
if (!isExplainedError(error)) logger.error('Error during startup:', error)
process.exitCode = 1
})