mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-05-25 18:04:01 +00:00
Only CommandExceptions should log at creation. (#99)
Before CommandError's where and they are used liberally for validating command arguments by returning a CommandResult for several possible options. Which gives a lot of spam. It's not necessary anyways since these should only be used for known errors.
This commit is contained in:
@@ -32,6 +32,7 @@ export class CommandException extends CommandError {
|
||||
public readonly exception: Error|unknown,
|
||||
message: string) {
|
||||
super(message)
|
||||
this.log();
|
||||
}
|
||||
|
||||
public static Result<Ok>(message: string, options: { exception: Error, exceptionKind: CommandExceptionKind }): CommandResult<Ok, CommandException> {
|
||||
|
||||
@@ -24,7 +24,6 @@ limitations under the License.
|
||||
* However, this file is modified and the modifications in this file
|
||||
* are NOT distributed, contributed, committed, or licensed under the Apache License.
|
||||
*/
|
||||
import { LogService } from "matrix-bot-sdk";
|
||||
|
||||
type ValidationMatchExpression<Ok, Err> = { ok?: (ok: Ok) => any, err?: (err: Err) => any};
|
||||
|
||||
@@ -90,7 +89,7 @@ export class CommandError {
|
||||
public constructor(
|
||||
public readonly message: string,
|
||||
) {
|
||||
this.log();
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,8 +101,4 @@ export class CommandError {
|
||||
public static Result<Ok>(message: string, _options = {}): CommandResult<Ok> {
|
||||
return CommandResult.Err(new CommandError(message));
|
||||
}
|
||||
|
||||
protected log(): void {
|
||||
LogService.info("CommandError", this.message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user