Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 799b2fa

Browse files
clydinhansl
authored andcommitted
refactor: rebase schematic option transformer exception
1 parent 7d8cee1 commit 799b2fa

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/angular_devkit/core/src/json/schema/registry.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ interface AjvValidationError {
3636
export class SchemaValidationException extends BaseException {
3737
public readonly errors: SchemaValidatorError[];
3838

39-
constructor(errors?: SchemaValidatorError[]) {
39+
constructor(
40+
errors?: SchemaValidatorError[],
41+
baseMessage = 'Schema validation failed with the following errors:',
42+
) {
4043
if (!errors || errors.length === 0) {
4144
super('Schema validation failed.');
4245

4346
return;
4447
}
4548

4649
const messages = SchemaValidationException.createMessages(errors);
47-
super(`Schema validation failed with the following errors:\n ${messages.join('\n ')}`);
50+
super(`${baseMessage}\n ${messages.join('\n ')}`);
4851
this.errors = errors;
4952
}
5053

packages/angular_devkit/schematics/tools/schema-option-transform.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {
9-
BaseException,
10-
deepCopy,
11-
schema,
12-
} from '@angular-devkit/core';
8+
import { deepCopy, schema } from '@angular-devkit/core';
139
import { Observable, of as observableOf } from 'rxjs';
1410
import { first, map, mergeMap } from 'rxjs/operators';
1511
import { SchematicDescription } from '../src';
@@ -19,11 +15,12 @@ export type SchematicDesc =
1915
SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription>;
2016

2117

22-
export class InvalidInputOptions extends BaseException {
23-
// tslint:disable-next-line:no-any
24-
constructor(options: any, public readonly errors: schema.SchemaValidatorError[]) {
25-
super(`Schematic input does not validate against the Schema: ${JSON.stringify(options)}\n`
26-
+ `Errors:\n ${schema.SchemaValidationException.createMessages(errors).join('\n ')}`);
18+
export class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
19+
constructor(options: T, errors: schema.SchemaValidatorError[]) {
20+
super(
21+
errors,
22+
`Schematic input does not validate against the Schema: ${JSON.stringify(options)}\nErrors:\n`,
23+
);
2724
}
2825
}
2926

0 commit comments

Comments
 (0)