swc/crates/swc_bundler/tests/.cache/deno/91a3278cffe125ea1d39ab32b68668328582caa0.ts
2021-11-09 20:42:49 +09:00

33 lines
662 B
TypeScript

// Loaded from https://deno.land/x/args@1.0.7/command-errors.ts
import {
ParseError,
} from "./types.ts";
import {
FlagError,
} from "./flag-errors.ts";
/**
* Class of error created by `CommandType::extract`
* @template ErrList Type of array of {@link FlagError}
*/
export class CommandError<
ErrList extends readonly FlagError[],
> implements ParseError, Iterable<FlagError> {
constructor(
/** Array of {@link FlagError} */
public readonly errors: ErrList,
) {}
public readonly toString = () =>
this.errors
.map((error) => error.toString())
.join("\n");
public *[Symbol.iterator]() {
yield* this.errors;
}
}