Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/
import {
BaseException,
InvalidJsonCharacterException,
JsonObject,
UnexpectedEndOfInputException,
isObservable,
normalize,
virtualFs,
Expand Down Expand Up @@ -52,8 +54,18 @@ export class CollectionCannotBeResolvedException extends BaseException {
}
}
export class InvalidCollectionJsonException extends BaseException {
constructor(_name: string, path: string) {
super(`Collection JSON at path ${JSON.stringify(path)} is invalid.`);
constructor(
_name: string,
path: string,
jsonException?: UnexpectedEndOfInputException | InvalidJsonCharacterException,
) {
let msg = `Collection JSON at path ${JSON.stringify(path)} is invalid.`;

if (jsonException) {
msg = `${msg} ${jsonException.message}`;
}

super(msg);
}
}
export class SchematicMissingFactoryException extends BaseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BaseException } from '@angular-devkit/core';
import {
BaseException,
InvalidJsonCharacterException,
UnexpectedEndOfInputException,
} from '@angular-devkit/core';
import * as core from '@angular-devkit/core/node';
import { dirname, join, resolve as resolvePath } from 'path';
import { RuleFactory } from '../src';
Expand All @@ -18,6 +22,7 @@ import {
CollectionCannotBeResolvedException,
CollectionMissingSchematicsMapException,
FileSystemEngineHostBase,
InvalidCollectionJsonException,
SchematicMissingFieldsException,
} from './file-system-engine-host-base';
import { readJsonFile } from './file-system-utility';
Expand Down Expand Up @@ -77,7 +82,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
if (name.replace(/\\/, '/').split('/').length > (name[0] == '@' ? 2 : 1)) {
try {
collectionPath = this._resolvePath(name, process.cwd());
} catch (_) {
} catch {
}
}

Expand All @@ -102,7 +107,13 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
return collectionPath;
}
} catch (e) {
if (
e instanceof InvalidJsonCharacterException || e instanceof UnexpectedEndOfInputException
) {
throw new InvalidCollectionJsonException(name, collectionPath, e);
}
}

throw new CollectionCannotBeResolvedException(name);
}

Expand Down