Have the same error message for file not found
This commit is contained in:
parent
a57ed5c4ae
commit
51baa4d8e0
2 changed files with 8 additions and 3 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
export class FileNotFoundError extends Error {
|
export class FileNotFoundError extends Error {
|
||||||
public constructor(message: string) {
|
public constructor(
|
||||||
|
message: string,
|
||||||
|
public readonly filePath: string
|
||||||
|
) {
|
||||||
super(message);
|
super(message);
|
||||||
this.name = "FileNotFoundError";
|
this.name = "FileNotFoundError";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,8 @@ export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
if (!(await this.fs.exists(path))) {
|
if (!(await this.fs.exists(path))) {
|
||||||
throw new FileNotFoundError(
|
throw new FileNotFoundError(
|
||||||
`File '${path}' not found before trying to ${operationName}`
|
`File not found before trying to ${operationName}`,
|
||||||
|
path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +132,8 @@ export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
throw error;
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundError(
|
throw new FileNotFoundError(
|
||||||
`File '${path}' not found when trying to ${operationName}`
|
`File not found when trying to ${operationName}`,
|
||||||
|
path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue