3
3
readJsonObjectFile as underlyingReadJsonObjectFile ,
4
4
writeJsonFile as underlyingWriteJsonFile ,
5
5
} from '@metamask/action-utils' ;
6
- import { coverError , isErrorWithCode } from './misc-utils' ;
6
+ import { wrapError , isErrorWithCode } from './misc-utils' ;
7
7
8
8
/**
9
9
* 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> {
16
16
try {
17
17
return await fs . promises . readFile ( filePath , 'utf8' ) ;
18
18
} catch ( error ) {
19
- throw coverError ( `Could not read file '${ filePath } '` , error ) ;
19
+ throw wrapError ( `Could not read file '${ filePath } '` , error ) ;
20
20
}
21
21
}
22
22
@@ -34,7 +34,7 @@ export async function writeFile(
34
34
try {
35
35
await fs . promises . writeFile ( filePath , content ) ;
36
36
} catch ( error ) {
37
- throw coverError ( `Could not write file '${ filePath } '` , error ) ;
37
+ throw wrapError ( `Could not write file '${ filePath } '` , error ) ;
38
38
}
39
39
}
40
40
@@ -56,7 +56,7 @@ export async function readJsonObjectFile(
56
56
try {
57
57
return await underlyingReadJsonObjectFile ( filePath ) ;
58
58
} catch ( error ) {
59
- throw coverError ( `Could not read JSON file '${ filePath } '` , error ) ;
59
+ throw wrapError ( `Could not read JSON file '${ filePath } '` , error ) ;
60
60
}
61
61
}
62
62
@@ -77,7 +77,7 @@ export async function writeJsonFile(
77
77
try {
78
78
await underlyingWriteJsonFile ( filePath , jsonValue ) ;
79
79
} catch ( error ) {
80
- throw coverError ( `Could not write JSON file '${ filePath } '` , error ) ;
80
+ throw wrapError ( `Could not write JSON file '${ filePath } '` , error ) ;
81
81
}
82
82
}
83
83
@@ -97,10 +97,7 @@ export async function fileExists(entryPath: string): Promise<boolean> {
97
97
return false ;
98
98
}
99
99
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 ) ;
104
101
}
105
102
}
106
103
@@ -118,7 +115,7 @@ export async function ensureDirectoryPathExists(
118
115
try {
119
116
return await fs . promises . mkdir ( directoryPath , { recursive : true } ) ;
120
117
} catch ( error ) {
121
- throw coverError (
118
+ throw wrapError (
122
119
`Could not create directory path '${ directoryPath } '` ,
123
120
error ,
124
121
) ;
@@ -136,6 +133,6 @@ export async function removeFile(filePath: string): Promise<void> {
136
133
try {
137
134
return await fs . promises . rm ( filePath , { force : true } ) ;
138
135
} catch ( error ) {
139
- throw coverError ( `Could not remove file '${ filePath } '` , error ) ;
136
+ throw wrapError ( `Could not remove file '${ filePath } '` , error ) ;
140
137
}
141
138
}
0 commit comments