33 readJsonObjectFile as underlyingReadJsonObjectFile ,
44 writeJsonFile as underlyingWriteJsonFile ,
55} from '@metamask/action-utils' ;
6- import { coverError , isErrorWithCode } from './misc-utils' ;
6+ import { wrapError , isErrorWithCode } from './misc-utils' ;
77
88/**
99 * Reads the file at the given path, assuming its content is encoded as UTF-8.
@@ -16,7 +16,7 @@ export async function readFile(filePath: string): Promise<string> {
1616 try {
1717 return await fs . promises . readFile ( filePath , 'utf8' ) ;
1818 } catch ( error ) {
19- throw coverError ( `Could not read file '${ filePath } '` , error ) ;
19+ throw wrapError ( `Could not read file '${ filePath } '` , error ) ;
2020 }
2121}
2222
@@ -34,7 +34,7 @@ export async function writeFile(
3434 try {
3535 await fs . promises . writeFile ( filePath , content ) ;
3636 } catch ( error ) {
37- throw coverError ( `Could not write file '${ filePath } '` , error ) ;
37+ throw wrapError ( `Could not write file '${ filePath } '` , error ) ;
3838 }
3939}
4040
@@ -56,7 +56,7 @@ export async function readJsonObjectFile(
5656 try {
5757 return await underlyingReadJsonObjectFile ( filePath ) ;
5858 } catch ( error ) {
59- throw coverError ( `Could not read JSON file '${ filePath } '` , error ) ;
59+ throw wrapError ( `Could not read JSON file '${ filePath } '` , error ) ;
6060 }
6161}
6262
@@ -77,7 +77,7 @@ export async function writeJsonFile(
7777 try {
7878 await underlyingWriteJsonFile ( filePath , jsonValue ) ;
7979 } catch ( error ) {
80- throw coverError ( `Could not write JSON file '${ filePath } '` , error ) ;
80+ throw wrapError ( `Could not write JSON file '${ filePath } '` , error ) ;
8181 }
8282}
8383
@@ -97,10 +97,7 @@ export async function fileExists(entryPath: string): Promise<boolean> {
9797 return false ;
9898 }
9999
100- throw coverError (
101- `Could not determine if file exists '${ entryPath } '` ,
102- error ,
103- ) ;
100+ throw wrapError ( `Could not determine if file exists '${ entryPath } '` , error ) ;
104101 }
105102}
106103
@@ -118,7 +115,7 @@ export async function ensureDirectoryPathExists(
118115 try {
119116 return await fs . promises . mkdir ( directoryPath , { recursive : true } ) ;
120117 } catch ( error ) {
121- throw coverError (
118+ throw wrapError (
122119 `Could not create directory path '${ directoryPath } '` ,
123120 error ,
124121 ) ;
@@ -136,6 +133,6 @@ export async function removeFile(filePath: string): Promise<void> {
136133 try {
137134 return await fs . promises . rm ( filePath , { force : true } ) ;
138135 } catch ( error ) {
139- throw coverError ( `Could not remove file '${ filePath } '` , error ) ;
136+ throw wrapError ( `Could not remove file '${ filePath } '` , error ) ;
140137 }
141138}
0 commit comments