@@ -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 {
@@ -199,31 +200,31 @@ export const importFileConvertAndLoadListener =
199
200
200
201
try {
201
202
if ( ! resourceFilePath . trim ( ) || ! fs . existsSync ( resourceFilePath ) ) {
202
- throw new Error ( 'Input file does not exist' ) ;
203
+ throw new Error ( text . backendError . inputFileDoesNotExist ) ;
203
204
}
204
205
205
206
try {
206
207
fs . accessSync ( resourceFilePath , fs . constants . R_OK ) ;
207
208
} catch ( error ) {
208
- throw new Error ( 'Permission error: cannot read input file' ) ;
209
+ throw new Error ( text . backendError . inputFilePermissionError ) ;
209
210
}
210
211
211
212
if ( ! opossumFilePath . trim ( ) ) {
212
- throw new Error ( 'No .opossum save location selected' ) ;
213
+ throw new Error ( text . backendError . opossumFileNotSelected ) ;
213
214
}
214
215
215
216
if ( ! opossumFilePath . endsWith ( '.opossum' ) ) {
216
- throw new Error ( 'Output file name must have .opossum extension' ) ;
217
+ throw new Error ( text . backendError . opossumFileWrongExtension ) ;
217
218
}
218
219
219
220
if ( ! fs . existsSync ( path . dirname ( opossumFilePath ) ) ) {
220
- throw new Error ( 'Output directory does not exist' ) ;
221
+ throw new Error ( text . backendError . opossumFileDirectoryDoesNotExist ) ;
221
222
}
222
223
223
224
try {
224
225
fs . accessSync ( path . dirname ( opossumFilePath ) , fs . constants . W_OK ) ;
225
226
} catch ( error ) {
226
- throw new Error ( 'Permission error: cannot write to output directory' ) ;
227
+ throw new Error ( text . backendError . opossumFilePermissionError ) ;
227
228
}
228
229
229
230
logger . info ( 'Converting input file to .opossum format' ) ;
@@ -259,19 +260,19 @@ export function getMergeFileAndLoadListener(
259
260
fileType : FileType ,
260
261
) => {
261
262
if ( ! inputFilePath . trim ( ) || ! fs . existsSync ( inputFilePath ) ) {
262
- throw new Error ( 'Input file does not exist' ) ;
263
+ throw new Error ( text . backendError . inputFileDoesNotExist ) ;
263
264
}
264
265
265
266
try {
266
267
fs . accessSync ( inputFilePath , fs . constants . R_OK ) ;
267
268
} catch ( error ) {
268
- throw new Error ( 'Permission error: cannot read input file' ) ;
269
+ throw new Error ( text . backendError . inputFilePermissionError ) ;
269
270
}
270
271
271
272
const currentOpossumFilePath = getGlobalBackendState ( ) . opossumFilePath ;
272
273
273
274
if ( ! currentOpossumFilePath ) {
274
- throw new Error ( 'No open file to merge into' ) ;
275
+ throw new Error ( text . backendError . noOpenFileToMergeInto ) ;
275
276
}
276
277
277
278
try {
@@ -280,9 +281,7 @@ export function getMergeFileAndLoadListener(
280
281
`${ currentOpossumFilePath } .backup` ,
281
282
) ;
282
283
} catch ( error ) {
283
- throw new Error (
284
- 'Unable to create backup of currently open Opossum file' ,
285
- ) ;
284
+ throw new Error ( text . backendError . cantCreateBackup ) ;
286
285
}
287
286
288
287
logger . info ( 'Merging input file into current .opossum file' ) ;
0 commit comments