@@ -24,6 +24,7 @@ import {
24
24
PackageInfo ,
25
25
SaveFileArgs ,
26
26
} from '../../shared/shared-types' ;
27
+ import { text } from '../../shared/text' ;
27
28
import { writeFile , writeOpossumFile } from '../../shared/write-file' ;
28
29
import { LoadedFileFormat } from '../enums/enums' ;
29
30
import {
@@ -206,31 +207,31 @@ export function getImportFileConvertAndLoadListener(
206
207
opossumFilePath : string ,
207
208
) => {
208
209
if ( ! resourceFilePath . trim ( ) || ! fs . existsSync ( resourceFilePath ) ) {
209
- throw new Error ( 'Input file does not exist' ) ;
210
+ throw new Error ( text . backendError . inputFileDoesNotExist ) ;
210
211
}
211
212
212
213
try {
213
214
fs . accessSync ( resourceFilePath , fs . constants . R_OK ) ;
214
215
} catch ( error ) {
215
- throw new Error ( 'Permission error: cannot read input file' ) ;
216
+ throw new Error ( text . backendError . inputFilePermissionError ) ;
216
217
}
217
218
218
219
if ( ! opossumFilePath . trim ( ) ) {
219
- throw new Error ( 'No .opossum save location selected' ) ;
220
+ throw new Error ( text . backendError . opossumFileNotSelected ) ;
220
221
}
221
222
222
223
if ( ! opossumFilePath . endsWith ( '.opossum' ) ) {
223
- throw new Error ( 'Output file name must have .opossum extension' ) ;
224
+ throw new Error ( text . backendError . opossumFileWrongExtension ) ;
224
225
}
225
226
226
227
if ( ! fs . existsSync ( path . dirname ( opossumFilePath ) ) ) {
227
- throw new Error ( 'Output directory does not exist' ) ;
228
+ throw new Error ( text . backendError . opossumFileDirectoryDoesNotExist ) ;
228
229
}
229
230
230
231
try {
231
232
fs . accessSync ( path . dirname ( opossumFilePath ) , fs . constants . W_OK ) ;
232
233
} catch ( error ) {
233
- throw new Error ( 'Permission error: cannot write to output directory' ) ;
234
+ throw new Error ( text . backendError . opossumFilePermissionError ) ;
234
235
}
235
236
236
237
logger . info ( 'Converting input file to .opossum format' ) ;
@@ -263,19 +264,19 @@ export function getMergeFileAndLoadListener(
263
264
fileType : FileType ,
264
265
) => {
265
266
if ( ! inputFilePath . trim ( ) || ! fs . existsSync ( inputFilePath ) ) {
266
- throw new Error ( 'Input file does not exist' ) ;
267
+ throw new Error ( text . backendError . inputFileDoesNotExist ) ;
267
268
}
268
269
269
270
try {
270
271
fs . accessSync ( inputFilePath , fs . constants . R_OK ) ;
271
272
} catch ( error ) {
272
- throw new Error ( 'Permission error: cannot read input file' ) ;
273
+ throw new Error ( text . backendError . inputFilePermissionError ) ;
273
274
}
274
275
275
276
const currentOpossumFilePath = getGlobalBackendState ( ) . opossumFilePath ;
276
277
277
278
if ( ! currentOpossumFilePath ) {
278
- throw new Error ( 'No open file to merge into' ) ;
279
+ throw new Error ( text . backendError . noOpenFileToMergeInto ) ;
279
280
}
280
281
281
282
try {
@@ -284,9 +285,7 @@ export function getMergeFileAndLoadListener(
284
285
`${ currentOpossumFilePath } .backup` ,
285
286
) ;
286
287
} catch ( error ) {
287
- throw new Error (
288
- 'Unable to create backup of currently open Opossum file' ,
289
- ) ;
288
+ throw new Error ( text . backendError . cantCreateBackup ) ;
290
289
}
291
290
292
291
logger . info ( 'Merging input file into current .opossum file' ) ;
0 commit comments