@seedcord/errors 0.3.3 → 0.4.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -8
- package/dist/{SeedcordError-Ce7zH47D.mjs → SeedcordError-BLQ8_el7.mjs} +146 -142
- package/dist/SeedcordError-BLQ8_el7.mjs.map +1 -0
- package/dist/{SeedcordError-0MrsUTlv.d.mts → SeedcordError-t1f0elt6.d.mts} +111 -126
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.d.mts +2 -20
- package/dist/internal.index.mjs +7 -26
- package/dist/internal.index.mjs.map +1 -1
- package/package.json +18 -15
- package/dist/SeedcordError-Ce7zH47D.mjs.map +0 -1
- package/dist/SeedcordError-DWH-0O1z.cjs +0 -551
- package/dist/SeedcordError-DWH-0O1z.cjs.map +0 -1
- package/dist/index.cjs +0 -12
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1
- package/dist/internal.index.cjs +0 -43
- package/dist/internal.index.cjs.map +0 -1
- package/dist/internal.index.d.cts +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,55 @@
|
|
|
1
|
-
<
|
|
1
|
+
<div align="center">
|
|
2
2
|
<picture>
|
|
3
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.seedcord.org/assets/wordmark-dark.webp" />
|
|
4
4
|
<img src="https://cdn.seedcord.org/assets/wordmark-light.webp" alt="seedcord" width="440" />
|
|
5
5
|
</picture>
|
|
6
|
-
</
|
|
6
|
+
</div>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
<div align="center">
|
|
9
|
+
<h3>The whole Discord bot, wired and typed</h3>
|
|
10
|
+
<a href="https://seedcord.org">Website</a> ·
|
|
11
|
+
<a href="https://guide.seedcord.org">Guide</a> ·
|
|
12
|
+
<a href="https://docs.seedcord.org">Reference</a> ·
|
|
13
|
+
<a href="https://discord.gg/DzFxY58WXf">Discord</a>
|
|
14
|
+
</div>
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
<br />
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
- Until a major v1.0.0 release for seedcord, expect breaking changes in minor versions.
|
|
14
|
-
- Documentation will come soon as well!
|
|
18
|
+
<div align="center">
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
[](https://www.npmjs.com/package/@seedcord/errors) [](https://nodejs.org) [](LICENSE)
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
## About
|
|
25
|
+
|
|
26
|
+
`@seedcord/errors` holds every error seedcord throws. Each one carries a registered code from `SeedcordErrorCode`, so a caller can branch on one specific failure.
|
|
27
|
+
|
|
28
|
+
Framework code never throws a raw `Error`. A third-party throw may be translated into one of these before you catch it.
|
|
29
|
+
|
|
30
|
+
Until v1.0.0, minor versions can break.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Your transport already re-exports this.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pnpm add @seedcord/errors
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
`isSeedcordError` narrows on the class and the code together:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { isSeedcordError, SeedcordErrorCode } from '@seedcord/errors';
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await run();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (isSeedcordError(error, 'SeedcordError', SeedcordErrorCode.CliCancelled)) return;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Called with one argument it narrows to any seedcord error.
|
|
@@ -5,22 +5,18 @@ import chalk from "chalk";
|
|
|
5
5
|
* All Seedcord error codes.
|
|
6
6
|
*/
|
|
7
7
|
let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
8
|
-
/** DISCORD_BOT_TOKEN is not present in the environment. */
|
|
9
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigMissingDiscordToken"] = 1001] = "ConfigMissingDiscordToken";
|
|
10
|
-
/** DISCORD_BOT_TOKEN is present but fails validation. */
|
|
11
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigIncorrectDiscordToken"] = 1002] = "ConfigIncorrectDiscordToken";
|
|
12
8
|
/** One or more configured emojis could not be resolved at startup. */
|
|
13
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigEmojiUnresolved"] =
|
|
9
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigEmojiUnresolved"] = 1001] = "ConfigEmojiUnresolved";
|
|
14
10
|
/** A webhook reporter's env var is set but fails webhook URL validation. */
|
|
15
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigWebhookUrlInvalid"] =
|
|
11
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigWebhookUrlInvalid"] = 1002] = "ConfigWebhookUrlInvalid";
|
|
16
12
|
/** A configured webhook does not exist on Discord (deleted, or a wrong id or token). */
|
|
17
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigWebhookNotFound"] =
|
|
18
|
-
/** DISCORD_PUBLIC_KEY is not present in the environment. */
|
|
19
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigMissingPublicKey"] = 1006] = "ConfigMissingPublicKey";
|
|
20
|
-
/** DISCORD_PUBLIC_KEY is present but fails validation. */
|
|
21
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigIncorrectPublicKey"] = 1007] = "ConfigIncorrectPublicKey";
|
|
13
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigWebhookNotFound"] = 1003] = "ConfigWebhookNotFound";
|
|
22
14
|
/** The generated route manifest was imported before `seedcord build` generated it. */
|
|
23
|
-
SeedcordErrorCode[SeedcordErrorCode["ConfigManifestNotGenerated"] =
|
|
15
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigManifestNotGenerated"] = 1004] = "ConfigManifestNotGenerated";
|
|
16
|
+
/** A required environment variable is not present. */
|
|
17
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigMissingEnv"] = 1005] = "ConfigMissingEnv";
|
|
18
|
+
/** An environment variable is present and fails validation. */
|
|
19
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigInvalidEnv"] = 1006] = "ConfigInvalidEnv";
|
|
24
20
|
/** Attempted to add lifecycle tasks after startup already completed. */
|
|
25
21
|
SeedcordErrorCode[SeedcordErrorCode["LifecycleAddAfterCompletion"] = 1101] = "LifecycleAddAfterCompletion";
|
|
26
22
|
/** Attempted to add lifecycle tasks while startup is still running. */
|
|
@@ -57,18 +53,16 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
57
53
|
SeedcordErrorCode[SeedcordErrorCode["CoreAccessorUnresolved"] = 1210] = "CoreAccessorUnresolved";
|
|
58
54
|
/** Interaction middleware decorated with disallowed event filters. */
|
|
59
55
|
SeedcordErrorCode[SeedcordErrorCode["DecoratorInteractionEventFilter"] = 1301] = "DecoratorInteractionEventFilter";
|
|
60
|
-
/** A decorator could not find the original method being decorated. */
|
|
61
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorMethodNotFound"] = 1302] = "DecoratorMethodNotFound";
|
|
62
56
|
/** A command decorator attempted to re-register an existing command scope. */
|
|
63
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandAlreadyRegistered"] =
|
|
57
|
+
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandAlreadyRegistered"] = 1302] = "DecoratorCommandAlreadyRegistered";
|
|
64
58
|
/** A global command decorator specified guild IDs, which is not allowed. */
|
|
65
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandGlobalWithGuilds"] =
|
|
59
|
+
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandGlobalWithGuilds"] = 1303] = "DecoratorCommandGlobalWithGuilds";
|
|
66
60
|
/** A guild command decorator omitted the required guild ID list. */
|
|
67
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandGuildWithoutGuilds"] =
|
|
61
|
+
SeedcordErrorCode[SeedcordErrorCode["DecoratorCommandGuildWithoutGuilds"] = 1304] = "DecoratorCommandGuildWithoutGuilds";
|
|
68
62
|
/** Middleware priority provided by the decorator was not a finite number. */
|
|
69
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorInvalidMiddlewarePriority"] =
|
|
63
|
+
SeedcordErrorCode[SeedcordErrorCode["DecoratorInvalidMiddlewarePriority"] = 1305] = "DecoratorInvalidMiddlewarePriority";
|
|
70
64
|
/** A WebhookLog subclass is missing its `@WebhookUrl` decorator. */
|
|
71
|
-
SeedcordErrorCode[SeedcordErrorCode["DecoratorWebhookUrlMissing"] =
|
|
65
|
+
SeedcordErrorCode[SeedcordErrorCode["DecoratorWebhookUrlMissing"] = 1306] = "DecoratorWebhookUrlMissing";
|
|
72
66
|
/** Two interaction handlers registered the same route within a scope. */
|
|
73
67
|
SeedcordErrorCode[SeedcordErrorCode["InteractionDuplicateRoute"] = 1401] = "InteractionDuplicateRoute";
|
|
74
68
|
/** Two different interaction middleware classes share a class name. */
|
|
@@ -133,6 +127,8 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
133
127
|
SeedcordErrorCode[SeedcordErrorCode["ColorOutOfRange"] = 1902] = "ColorOutOfRange";
|
|
134
128
|
/** A plugin's constructor rejected its options through `rejectOptions`. */
|
|
135
129
|
SeedcordErrorCode[SeedcordErrorCode["PluginOptionsRejected"] = 2001] = "PluginOptionsRejected";
|
|
130
|
+
/** Two or more plugins threw while disposing. */
|
|
131
|
+
SeedcordErrorCode[SeedcordErrorCode["PluginDisposeFailures"] = 2002] = "PluginDisposeFailures";
|
|
136
132
|
/** Mongoose service class is missing the `@RegisterMongooseService` decorator. */
|
|
137
133
|
SeedcordErrorCode[SeedcordErrorCode["PluginMongooseServiceDecoratorMissing"] = 2101] = "PluginMongooseServiceDecoratorMissing";
|
|
138
134
|
/** Mongoose client failed to establish a connection. */
|
|
@@ -173,72 +169,54 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
173
169
|
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidExport"] = 3101] = "CliConfigInvalidExport";
|
|
174
170
|
/** Config is missing the required instance string. */
|
|
175
171
|
SeedcordErrorCode[SeedcordErrorCode["CliConfigMissingInstance"] = 3102] = "CliConfigMissingInstance";
|
|
176
|
-
/** Config root was provided but not a string. */
|
|
177
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidRoot"] = 3103] = "CliConfigInvalidRoot";
|
|
178
172
|
/** Unable to locate a Seedcord config file. */
|
|
179
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigNotFound"] =
|
|
173
|
+
SeedcordErrorCode[SeedcordErrorCode["CliConfigNotFound"] = 3103] = "CliConfigNotFound";
|
|
180
174
|
/** CLI entry file does not exist. */
|
|
181
|
-
SeedcordErrorCode[SeedcordErrorCode["CliEntryNotFound"] =
|
|
175
|
+
SeedcordErrorCode[SeedcordErrorCode["CliEntryNotFound"] = 3104] = "CliEntryNotFound";
|
|
182
176
|
/** tsx failed to import the provided entry file. */
|
|
183
|
-
SeedcordErrorCode[SeedcordErrorCode["CliTsxImportFailed"] =
|
|
177
|
+
SeedcordErrorCode[SeedcordErrorCode["CliTsxImportFailed"] = 3105] = "CliTsxImportFailed";
|
|
184
178
|
/** Native import and jiti fallback both failed. */
|
|
185
|
-
SeedcordErrorCode[SeedcordErrorCode["CliImportFailed"] =
|
|
179
|
+
SeedcordErrorCode[SeedcordErrorCode["CliImportFailed"] = 3106] = "CliImportFailed";
|
|
186
180
|
/** Seedcord instance export is missing a start() method. */
|
|
187
|
-
SeedcordErrorCode[SeedcordErrorCode["CliInstanceInvalid"] =
|
|
181
|
+
SeedcordErrorCode[SeedcordErrorCode["CliInstanceInvalid"] = 3107] = "CliInstanceInvalid";
|
|
188
182
|
/** Seedcord instance threw during startup. */
|
|
189
|
-
SeedcordErrorCode[SeedcordErrorCode["CliStartFailed"] =
|
|
183
|
+
SeedcordErrorCode[SeedcordErrorCode["CliStartFailed"] = 3108] = "CliStartFailed";
|
|
190
184
|
/** Config is missing the required entry string. */
|
|
191
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigMissingEntry"] =
|
|
192
|
-
/** Config build options must be an object when provided. */
|
|
193
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidBuild"] = 3111] = "CliConfigInvalidBuild";
|
|
194
|
-
/** Config build outDir must be a string when provided. */
|
|
195
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidBuildOutDir"] = 3112] = "CliConfigInvalidBuildOutDir";
|
|
196
|
-
/** Config build tsconfig must be a string when provided. */
|
|
197
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidBuildTsconfig"] = 3113] = "CliConfigInvalidBuildTsconfig";
|
|
198
|
-
/** Config build bootstrap must be a string when provided. */
|
|
199
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidBuildBootstrap"] = 3114] = "CliConfigInvalidBuildBootstrap";
|
|
185
|
+
SeedcordErrorCode[SeedcordErrorCode["CliConfigMissingEntry"] = 3109] = "CliConfigMissingEntry";
|
|
200
186
|
/** Entry file must be inside the configured root directory. */
|
|
201
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigEntryOutsideRoot"] =
|
|
187
|
+
SeedcordErrorCode[SeedcordErrorCode["CliConfigEntryOutsideRoot"] = 3110] = "CliConfigEntryOutsideRoot";
|
|
202
188
|
/** Unable to locate a TypeScript config file for builds. */
|
|
203
|
-
SeedcordErrorCode[SeedcordErrorCode["CliBuildTsconfigNotFound"] =
|
|
189
|
+
SeedcordErrorCode[SeedcordErrorCode["CliBuildTsconfigNotFound"] = 3111] = "CliBuildTsconfigNotFound";
|
|
204
190
|
/** TypeScript reported diagnostics during emit. */
|
|
205
|
-
SeedcordErrorCode[SeedcordErrorCode["CliBuildFailed"] =
|
|
191
|
+
SeedcordErrorCode[SeedcordErrorCode["CliBuildFailed"] = 3112] = "CliBuildFailed";
|
|
206
192
|
/** Unable to write the generated bootstrap file. */
|
|
207
|
-
SeedcordErrorCode[SeedcordErrorCode["CliBootstrapWriteFailed"] =
|
|
208
|
-
/** Config tsconfig must be a string when provided. */
|
|
209
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidTsconfig"] = 3119] = "CliConfigInvalidTsconfig";
|
|
210
|
-
/** Config hmr options must be an object when provided. */
|
|
211
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidHmr"] = 3120] = "CliConfigInvalidHmr";
|
|
212
|
-
/** Config hmr restart patterns must be an array of strings when provided. */
|
|
213
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidHmrRestart"] = 3121] = "CliConfigInvalidHmrRestart";
|
|
193
|
+
SeedcordErrorCode[SeedcordErrorCode["CliBootstrapWriteFailed"] = 3113] = "CliBootstrapWriteFailed";
|
|
214
194
|
/** Two commands resolve to the same slash route during codegen. */
|
|
215
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCodegenDuplicateRoute"] =
|
|
195
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCodegenDuplicateRoute"] = 3114] = "CliCodegenDuplicateRoute";
|
|
216
196
|
/** The commands directory could not be read during codegen. */
|
|
217
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCodegenCommandsDirUnreadable"] =
|
|
197
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCodegenCommandsDirUnreadable"] = 3115] = "CliCodegenCommandsDirUnreadable";
|
|
218
198
|
/** Two context-menu commands of the same kind share a name during codegen. */
|
|
219
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCodegenDuplicateContextMenu"] =
|
|
199
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCodegenDuplicateContextMenu"] = 3116] = "CliCodegenDuplicateContextMenu";
|
|
220
200
|
/** Could not resolve the application from the bot token during `commands --clean`. */
|
|
221
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCleanAppFetchFailed"] =
|
|
201
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCleanAppFetchFailed"] = 3117] = "CliCleanAppFetchFailed";
|
|
222
202
|
/** `commands --clean` ran with neither --guild nor --all-guilds. */
|
|
223
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCleanNoGuilds"] =
|
|
203
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCleanNoGuilds"] = 3118] = "CliCleanNoGuilds";
|
|
224
204
|
/** `commands --clean` combined --purge with --all-guilds, which would wipe every guild. */
|
|
225
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCleanPurgeAllGuilds"] =
|
|
205
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCleanPurgeAllGuilds"] = 3119] = "CliCleanPurgeAllGuilds";
|
|
226
206
|
/** An interactive prompt was cancelled (Ctrl-C), so the command aborts without changes. */
|
|
227
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCancelled"] =
|
|
207
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCancelled"] = 3120] = "CliCancelled";
|
|
228
208
|
/** `commands --clean --all-guilds` matched more guilds than the safety threshold without `--yes`. */
|
|
229
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCleanLargeBotUnconfirmed"] =
|
|
209
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCleanLargeBotUnconfirmed"] = 3121] = "CliCleanLargeBotUnconfirmed";
|
|
230
210
|
/** `commands --clean --apply` ran in a non-interactive environment without `--yes`, where it cannot prompt. */
|
|
231
|
-
SeedcordErrorCode[SeedcordErrorCode["CliCleanApplyNeedsYes"] =
|
|
232
|
-
/** Config hmr rollback flag must be a boolean when provided. */
|
|
233
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidHmrRollback"] = 3131] = "CliConfigInvalidHmrRollback";
|
|
234
|
-
/** Config tunnel must be a boolean or an https URL when provided. */
|
|
235
|
-
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidTunnel"] = 3132] = "CliConfigInvalidTunnel";
|
|
211
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCleanApplyNeedsYes"] = 3122] = "CliCleanApplyNeedsYes";
|
|
236
212
|
/** The cloudflared metrics server never reported a quick-tunnel hostname. */
|
|
237
|
-
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUrlUnavailable"] =
|
|
213
|
+
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUrlUnavailable"] = 3123] = "CliTunnelUrlUnavailable";
|
|
238
214
|
/** Discord rejected the tunnel URL as an interactions endpoint. */
|
|
239
|
-
SeedcordErrorCode[SeedcordErrorCode["CliTunnelNotVerified"] =
|
|
215
|
+
SeedcordErrorCode[SeedcordErrorCode["CliTunnelNotVerified"] = 3124] = "CliTunnelNotVerified";
|
|
240
216
|
/** The tunnel URL never answered its health probe. */
|
|
241
|
-
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUnreachable"] =
|
|
217
|
+
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUnreachable"] = 3125] = "CliTunnelUnreachable";
|
|
218
|
+
/** A config field is present with the wrong shape. */
|
|
219
|
+
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidField"] = 3126] = "CliConfigInvalidField";
|
|
242
220
|
/** A create prompt was cancelled (Ctrl-C), and nothing has been written yet. */
|
|
243
221
|
SeedcordErrorCode[SeedcordErrorCode["CreateCancelled"] = 3201] = "CreateCancelled";
|
|
244
222
|
/** A flag supplied an answer for a question the earlier answers skip. */
|
|
@@ -254,18 +232,38 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
254
232
|
return SeedcordErrorCode;
|
|
255
233
|
}({});
|
|
256
234
|
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/palette.ts
|
|
237
|
+
const BRAND = {
|
|
238
|
+
flesh: "#f04e36",
|
|
239
|
+
rind: "#6fab49",
|
|
240
|
+
pith: "#f8f6e8"
|
|
241
|
+
};
|
|
242
|
+
const paint = {
|
|
243
|
+
sky: chalk.hex("#8fc7ff"),
|
|
244
|
+
iris: chalk.hex("#e29bff"),
|
|
245
|
+
mint: chalk.hex("#66d98a"),
|
|
246
|
+
amber: chalk.hex("#ffc061"),
|
|
247
|
+
coral: chalk.hex("#ff6b85"),
|
|
248
|
+
flesh: chalk.hex(BRAND.flesh),
|
|
249
|
+
rind: chalk.hex(BRAND.rind),
|
|
250
|
+
pith: chalk.hex(BRAND.pith),
|
|
251
|
+
mute: chalk.dim,
|
|
252
|
+
bold: chalk.bold,
|
|
253
|
+
italic: chalk.italic,
|
|
254
|
+
underline: chalk.underline
|
|
255
|
+
};
|
|
256
|
+
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/ErrorMessages.ts
|
|
259
259
|
/** @internal */
|
|
260
260
|
const messages = {
|
|
261
|
-
[
|
|
262
|
-
[
|
|
263
|
-
[
|
|
264
|
-
[
|
|
265
|
-
[
|
|
266
|
-
[
|
|
267
|
-
[1005]: (envKey) => `The webhook behind ${envKey} does not exist on Discord.`,
|
|
268
|
-
[1003]: (count, failures) => `Could not resolve ${count} configured emoji${count === 1 ? "" : "s"} at startup.\n${failures}`,
|
|
261
|
+
[1005]: (name) => `Missing ${name} environment variable.`,
|
|
262
|
+
[1006]: (name, expected) => expected ? `Invalid ${name} value. Expected ${expected}.` : `Invalid ${name} value.`,
|
|
263
|
+
[1004]: () => "The route manifest is generated by `seedcord build`. Run the build before importing it.",
|
|
264
|
+
[1002]: (envKey) => `${envKey} is not a well-formed Discord webhook url.`,
|
|
265
|
+
[1003]: (envKey) => `The webhook behind ${envKey} does not exist on Discord.`,
|
|
266
|
+
[1001]: (count, failures) => `Could not resolve ${count} configured emoji${count === 1 ? "" : "s"} at startup.\n${failures}`,
|
|
269
267
|
[1101]: () => "Cannot add tasks after startup sequence has already completed.",
|
|
270
268
|
[1102]: () => "Cannot add tasks while startup sequence is in progress.",
|
|
271
269
|
[1103]: () => "Cannot remove tasks while startup sequence is in progress.",
|
|
@@ -284,22 +282,21 @@ const messages = {
|
|
|
284
282
|
[1209]: () => "The bot's application id could not be resolved.",
|
|
285
283
|
[1210]: (accessor, key) => `${accessor}.${key} has no value yet. ${accessor} fills during startup, and a read at the top of a file runs before that.`,
|
|
286
284
|
[1301]: () => "Interaction middleware cannot specify event filters.",
|
|
287
|
-
[1302]: () => "
|
|
288
|
-
[1303]: (
|
|
289
|
-
[1304]: () => "RegisterCommand(\"
|
|
290
|
-
[1305]: () => "
|
|
291
|
-
[1306]: () =>
|
|
292
|
-
[1307]: (className) => `${className} extends WebhookLog and needs a @WebhookUrl decorator naming its env var.`,
|
|
285
|
+
[1302]: (commandName, existingScope, requestedScope) => `Command "${commandName}" is already registered as a "${existingScope}" command and cannot be re-registered as a "${requestedScope}" command.`,
|
|
286
|
+
[1303]: () => "RegisterCommand(\"global\") cannot have guilds specified.",
|
|
287
|
+
[1304]: () => "RegisterCommand(\"guild\") requires a non-empty guilds array.",
|
|
288
|
+
[1305]: () => "Middleware priority must be a finite number.",
|
|
289
|
+
[1306]: (className) => `${className} extends WebhookLog and needs a @WebhookUrl decorator naming its env var.`,
|
|
293
290
|
[1401]: (route, first, second) => `Two interaction handlers resolve to the same route \`${route}\`. Registered by ${first} and ${second}. Rename one.`,
|
|
294
291
|
[1402]: (name) => `Two different interaction middleware classes share the name \`${name}\`. Rename one so they do not collide.`,
|
|
295
292
|
[1403]: (route, exportName, from) => `Route \`${route}\` loads \`${exportName}\` from ${from}, which exports no such name.`,
|
|
296
293
|
[1404]: (keys, exportName, from) => `Subscriber row for \`${keys}\` loads \`${exportName}\` from ${from}, which does not extend Subscriber.`,
|
|
297
294
|
[1405]: (route, from) => `Route \`${route}\` failed to import ${from}.`,
|
|
298
|
-
[1501]: (method, reason, alternative, routeId) => `${
|
|
299
|
-
[1502]: (componentClass, index, detail, routeId) => `${
|
|
300
|
-
[1503]: (method, targetId, routeId) => `${
|
|
301
|
-
[1504]: (method, routeId) => `${
|
|
302
|
-
[1505]: (method, routeId) => `The interaction callback for ${
|
|
295
|
+
[1501]: (method, reason, alternative, routeId) => `${paint.sky(`${method}()`)} was called when ${reason}.\n${alternative} (route ${paint.mute(routeId)})`,
|
|
296
|
+
[1502]: (componentClass, index, detail, routeId) => `${paint.sky(componentClass)} at components[${index}] failed to serialize: ${detail.replace(/\.$/, "")}. (route ${paint.mute(routeId)})`,
|
|
297
|
+
[1503]: (method, targetId, routeId) => `${paint.sky(`${method}()`)} was passed message ${targetId}, which this interaction did not send.\nPass a message this interaction sent, returned by reply(), followUp(), edit(), or update(). (route ${paint.mute(routeId)})`,
|
|
298
|
+
[1504]: (method, routeId) => `${paint.sky(`${method}()`)} was called on a modal opened from a command, which has no source message.\nUse reply() or defer() instead. (route ${paint.mute(routeId)})`,
|
|
299
|
+
[1505]: (method, routeId) => `The interaction callback for ${paint.sky(`${method}()`)} returned no message. (route ${paint.mute(routeId)})`,
|
|
303
300
|
[1601]: (prefix) => `customId prefix ${JSON.stringify(prefix)} must be a non-empty string without a colon or control character.`,
|
|
304
301
|
[1602]: (field) => `customId field name ${JSON.stringify(field)} is integer-like, which JS reorders. Use a non-numeric name.`,
|
|
305
302
|
[1603]: (field) => `customId field ${JSON.stringify(field)} uses oneOf() with no choices.`,
|
|
@@ -322,6 +319,7 @@ const messages = {
|
|
|
322
319
|
[1901]: (value) => `Cannot convert ${value} into a color.`,
|
|
323
320
|
[1902]: () => "Color must be within the range 0 to 16777215 (0xffffff).",
|
|
324
321
|
[2001]: (pluginName, reason) => `${pluginName} rejected its options, ${reason.replace(/\.$/, "")}.`,
|
|
322
|
+
[2002]: (count) => `${count} plugins failed to dispose.`,
|
|
325
323
|
[2101]: (className) => `Missing @RegisterMongooseService on ${className}.`,
|
|
326
324
|
[2102]: (databaseName) => databaseName ? `Could not connect to MongoDB (${databaseName}).` : "Could not connect to MongoDB.",
|
|
327
325
|
[2103]: () => "Failed to disconnect from MongoDB cleanly during shutdown.",
|
|
@@ -342,39 +340,30 @@ const messages = {
|
|
|
342
340
|
[2212]: (databaseName) => `Failed to ensure database ${databaseName} exists.`,
|
|
343
341
|
[3101]: () => "Config file must default export an object.",
|
|
344
342
|
[3102]: () => "Config must include an `instance` string that points to your Seedcord default export.",
|
|
345
|
-
[3103]: () =>
|
|
346
|
-
[
|
|
347
|
-
[3110]: () =>
|
|
348
|
-
[
|
|
349
|
-
[
|
|
350
|
-
[
|
|
351
|
-
[
|
|
352
|
-
[
|
|
353
|
-
[
|
|
354
|
-
[
|
|
355
|
-
[
|
|
356
|
-
[
|
|
357
|
-
[
|
|
358
|
-
[3116]: (
|
|
359
|
-
[3117]: (
|
|
360
|
-
[3118]: (
|
|
361
|
-
[3119]: () => "
|
|
362
|
-
[3120]: () => "
|
|
363
|
-
[3121]: () =>
|
|
364
|
-
[
|
|
365
|
-
[
|
|
366
|
-
[
|
|
367
|
-
[
|
|
368
|
-
[
|
|
369
|
-
[3126]: () => "No guilds given. Pass --guild <ids...> or --all-guilds. Global commands are never touched.",
|
|
370
|
-
[3127]: () => "--purge cannot be combined with --all-guilds. Use --guild <ids> to purge specific guilds.",
|
|
371
|
-
[3128]: () => "Cancelled.",
|
|
372
|
-
[3129]: (count) => `Refusing to scan ${count} guilds without confirmation. Re-run with --yes, or name specific guilds with --guild <ids>.`,
|
|
373
|
-
[3130]: () => "Refusing to delete without confirmation in a non-interactive environment. Re-run with --yes.",
|
|
374
|
-
[3132]: () => "Config `tunnel` must be a boolean or an https URL.",
|
|
375
|
-
[3133]: (seconds) => `cloudflared did not report a tunnel URL within ${seconds}s. Check that the binary runs and that the network allows it.`,
|
|
376
|
-
[3134]: (url) => `Discord rejected ${url} as an interactions endpoint.`,
|
|
377
|
-
[3135]: (url, seconds) => `${url} did not answer within ${seconds}s, so nothing was PATCHed to Discord.`,
|
|
343
|
+
[3103]: (baseDir, candidates) => `Unable to locate a Seedcord config in ${baseDir}. Searched for ${candidates.join(", ")}.`,
|
|
344
|
+
[3109]: () => "Config must include an `entry` string that points to your startup script.",
|
|
345
|
+
[3110]: (entryPath, root) => `Entry file ${entryPath} must reside inside configured root ${root}.`,
|
|
346
|
+
[3104]: (entryPath) => `Cannot find entry file at ${entryPath}.`,
|
|
347
|
+
[3105]: (entryPath, reason) => `Failed to import ${entryPath} via tsx: ${reason}`,
|
|
348
|
+
[3106]: (entryPath, nativeReason, fallbackReason) => `Failed to import ${entryPath}: ${nativeReason} (the jiti fallback also failed: ${fallbackReason})`,
|
|
349
|
+
[3107]: () => "Seedcord instance must default export an object with a start() method.",
|
|
350
|
+
[3108]: (instancePath, reason) => `Failed to start Seedcord from ${instancePath}: ${reason}`,
|
|
351
|
+
[3111]: (hint) => `Unable to resolve a tsconfig for builds (${hint}). Provide build.tsconfig or add tsconfig.build.json / tsconfig.json.`,
|
|
352
|
+
[3112]: (diagnostics) => `TypeScript build failed:\n${diagnostics}`,
|
|
353
|
+
[3113]: (targetPath, reason) => `Failed to write bootstrap file at ${targetPath}: ${reason}`,
|
|
354
|
+
[3114]: (route, firstFile, secondFile) => `Two commands resolve to the same slash route \`${route}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
355
|
+
[3115]: (dir, reason) => `Could not read the commands directory ${dir} during codegen. ${reason}`,
|
|
356
|
+
[3116]: (kind, name, firstFile, secondFile) => `Two ${kind} context-menu commands share the name \`${name}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
357
|
+
[3117]: (reason) => `Could not resolve the application from the bot token. ${reason}`,
|
|
358
|
+
[3118]: () => "No guilds given. Pass --guild <ids...> or --all-guilds. Global commands are never touched.",
|
|
359
|
+
[3119]: () => "--purge cannot be combined with --all-guilds. Use --guild <ids> to purge specific guilds.",
|
|
360
|
+
[3120]: () => "Cancelled.",
|
|
361
|
+
[3121]: (count) => `Refusing to scan ${count} guilds without confirmation. Re-run with --yes, or name specific guilds with --guild <ids>.`,
|
|
362
|
+
[3122]: () => "Refusing to delete without confirmation in a non-interactive environment. Re-run with --yes.",
|
|
363
|
+
[3123]: (seconds) => `cloudflared did not report a tunnel URL within ${seconds}s. Check that the binary runs and that the network allows it.`,
|
|
364
|
+
[3124]: (url) => `Discord rejected ${url} as an interactions endpoint.`,
|
|
365
|
+
[3125]: (url, seconds) => `${url} did not answer within ${seconds}s, so nothing was PATCHed to Discord.`,
|
|
366
|
+
[3126]: (field, expected) => `Config \`${field}\` must be ${expected} when provided.`,
|
|
378
367
|
[3201]: () => "Cancelled.",
|
|
379
368
|
[3202]: (flag) => `The --${flag} flag does not apply to the answers you gave.`,
|
|
380
369
|
[3203]: (flag, reason) => `--${flag}: ${reason}`,
|
|
@@ -408,81 +397,96 @@ function resolveMessage(code, args) {
|
|
|
408
397
|
return formatSeedcordErrorMessage(code, args);
|
|
409
398
|
}
|
|
410
399
|
function formatErrorName(name, _identifier, code) {
|
|
411
|
-
return `${
|
|
400
|
+
return `${paint.coral.bold(name)}[${paint.mute(code)}]`;
|
|
401
|
+
}
|
|
402
|
+
const kIdentifier = Symbol.for("seedcord.errors.identifier");
|
|
403
|
+
const CODED = Symbol.for("seedcord.errors.coded");
|
|
404
|
+
function brand(prototype) {
|
|
405
|
+
Object.defineProperty(prototype, CODED, { value: true });
|
|
406
|
+
}
|
|
407
|
+
function isCoded(error) {
|
|
408
|
+
return typeof error === "object" && error !== null && CODED in error;
|
|
412
409
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Base class for Seedcord errors.
|
|
415
|
-
*/
|
|
416
410
|
var SeedcordError = class extends Error {
|
|
417
411
|
code;
|
|
418
|
-
|
|
412
|
+
[kIdentifier];
|
|
419
413
|
type = "SeedcordError";
|
|
420
414
|
constructor(code, ...rest) {
|
|
421
415
|
const { args, options } = resolveCtorInputs(rest);
|
|
422
416
|
const message = resolveMessage(code, args);
|
|
423
417
|
super(message, options);
|
|
424
418
|
this.code = code;
|
|
425
|
-
this
|
|
426
|
-
this.name = formatErrorName(new.target.name, this
|
|
419
|
+
this[kIdentifier] = resolveIdentifier(code);
|
|
420
|
+
this.name = formatErrorName(new.target.name, this[kIdentifier], this.code);
|
|
427
421
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
428
422
|
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, new.target);
|
|
429
423
|
}
|
|
430
424
|
};
|
|
431
|
-
|
|
432
|
-
* TypeError class for Seedcord errors.
|
|
433
|
-
*/
|
|
425
|
+
brand(SeedcordError.prototype);
|
|
434
426
|
var SeedcordTypeError = class extends TypeError {
|
|
435
427
|
code;
|
|
436
|
-
|
|
428
|
+
[kIdentifier];
|
|
437
429
|
type = "SeedcordTypeError";
|
|
438
430
|
constructor(code, ...rest) {
|
|
439
431
|
const { args, options } = resolveCtorInputs(rest);
|
|
440
432
|
const message = resolveMessage(code, args);
|
|
441
433
|
super(message, options);
|
|
442
434
|
this.code = code;
|
|
443
|
-
this
|
|
444
|
-
this.name = formatErrorName(new.target.name, this
|
|
435
|
+
this[kIdentifier] = resolveIdentifier(code);
|
|
436
|
+
this.name = formatErrorName(new.target.name, this[kIdentifier], this.code);
|
|
445
437
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
446
438
|
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, new.target);
|
|
447
439
|
}
|
|
448
440
|
};
|
|
449
|
-
|
|
450
|
-
* RangeError class for Seedcord errors.
|
|
451
|
-
*/
|
|
441
|
+
brand(SeedcordTypeError.prototype);
|
|
452
442
|
var SeedcordRangeError = class extends RangeError {
|
|
453
443
|
code;
|
|
454
|
-
|
|
444
|
+
[kIdentifier];
|
|
455
445
|
type = "SeedcordRangeError";
|
|
456
446
|
constructor(code, ...rest) {
|
|
457
447
|
const { args, options } = resolveCtorInputs(rest);
|
|
458
448
|
const message = resolveMessage(code, args);
|
|
459
449
|
super(message, options);
|
|
460
450
|
this.code = code;
|
|
461
|
-
this
|
|
462
|
-
this.name = formatErrorName(new.target.name, this
|
|
451
|
+
this[kIdentifier] = resolveIdentifier(code);
|
|
452
|
+
this.name = formatErrorName(new.target.name, this[kIdentifier], this.code);
|
|
453
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
454
|
+
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, new.target);
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
brand(SeedcordRangeError.prototype);
|
|
458
|
+
var SeedcordAggregateError = class extends AggregateError {
|
|
459
|
+
code;
|
|
460
|
+
[kIdentifier];
|
|
461
|
+
type = "SeedcordAggregateError";
|
|
462
|
+
constructor(code, errors, ...rest) {
|
|
463
|
+
const { args, options } = resolveCtorInputs(rest);
|
|
464
|
+
const message = resolveMessage(code, args);
|
|
465
|
+
super(errors, message, options);
|
|
466
|
+
this.code = code;
|
|
467
|
+
this[kIdentifier] = resolveIdentifier(code);
|
|
468
|
+
this.name = formatErrorName(new.target.name, this[kIdentifier], this.code);
|
|
463
469
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
464
470
|
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, new.target);
|
|
465
471
|
}
|
|
466
472
|
};
|
|
473
|
+
brand(SeedcordAggregateError.prototype);
|
|
467
474
|
/**
|
|
468
475
|
* Determines whether an unknown value is a Seedcord error, with optional narrowing by class and error code.
|
|
469
476
|
*
|
|
470
477
|
* @param error - The value to inspect.
|
|
471
|
-
* @param type - Optional error class discriminator
|
|
478
|
+
* @param type - Optional error class discriminator.
|
|
472
479
|
* @param code - Optional {@link SeedcordErrorCode} discriminator to narrow by code.
|
|
473
480
|
* @typeParam Type - What kind of {@link SeedcordErrorTypeString} to filter by.
|
|
474
481
|
* @typeParam Code - The specific {@link SeedcordErrorCode} to filter by.
|
|
475
482
|
*/
|
|
476
483
|
function isSeedcordError(error, type, code) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const isSeedcordRangeErrorInstance = error instanceof SeedcordRangeError && error.type === "SeedcordRangeError";
|
|
480
|
-
if (!isSeedcordErrorInstance && !isSeedcordTypeErrorInstance && !isSeedcordRangeErrorInstance) return false;
|
|
481
|
-
if (!(type ? type === "SeedcordError" && isSeedcordErrorInstance || type === "SeedcordTypeError" && isSeedcordTypeErrorInstance || type === "SeedcordRangeError" && isSeedcordRangeErrorInstance : true)) return false;
|
|
484
|
+
if (!isCoded(error)) return false;
|
|
485
|
+
if (type && error.type !== type) return false;
|
|
482
486
|
if (code === void 0) return true;
|
|
483
|
-
return error
|
|
487
|
+
return error[kIdentifier] === resolveIdentifier(code);
|
|
484
488
|
}
|
|
485
489
|
|
|
486
490
|
//#endregion
|
|
487
|
-
export {
|
|
488
|
-
//# sourceMappingURL=SeedcordError-
|
|
491
|
+
export { isSeedcordError as a, SeedcordErrorCode as c, SeedcordTypeError as i, SeedcordError as n, BRAND as o, SeedcordRangeError as r, paint as s, SeedcordAggregateError as t };
|
|
492
|
+
//# sourceMappingURL=SeedcordError-BLQ8_el7.mjs.map
|