-
-
Notifications
You must be signed in to change notification settings - Fork 86
SettingsError Event #708
Comments
I disagree to this, but I see an usecase for a klasa/src/lib/settings/gateway/Gateway.js Line 73 in 99eeec8
|
const { errors } = await guild.settings.update(key, value)
if (errors.length) this.client.emit('error', errors.join('\n'))
const updatedUser = await user.settings.update(key, value)
if (updatedUser.errors.length) this.client.emit(`error`, updatedUser.errors.join(`\n`))
return null VS: await guild.settings.update(key, value)
return user.settings.update(key, value) 7 lines down to 2 lines of code. Individually handling emitting errors is kinda bad when u have a larger bot. If the await guild.settings.update(key, value, { emitErrors: true })
return user.settings.update(key, value, { emitErrors: true }) Then somewhere in the if (options.emitErrors && errors.length) client.emit....... |
Alternative, using what's already available in the Settings branch: await guild.settings.update(key, value, { throwOnError: true });
await user.settings.update(key, value, { throwOnError: true }); |
Other possibilities:
|
@Skillz4Killz is the current (and next with #752) interface enough satisfactory to close this issue? |
@kyranet I believe throwOnError solved all my needs already. |
Describe your proposal
It would be really nice to have a event that is emitted whenever there is some error in Settings.
Use-Cases for your proposal
This is the current way of handling errors. Duplicate this over 100s of files on larger bots and you get a lot of extra lines that just are not needed if there was a nice event handler for these errors.
Current Workaround: Using the functions plugin
Expected and actual behavior
It would be nice to do something like below and any and all errors are emitted in the
settingsError
event.Further details
N/A
The text was updated successfully, but these errors were encountered: