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:
Gnuxie
2023-09-07 15:59:20 +01:00
committed by GitHub
parent 4b656306ed
commit 26468afcde
2 changed files with 2 additions and 6 deletions
@@ -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> {
+1 -6
View File
@@ -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);
}
}