Skip to content

Commit

Permalink
Improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Dec 14, 2023
1 parent 98f60f3 commit afcb74e
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 347 deletions.
12 changes: 8 additions & 4 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ if (!fs.existsSync(customStylesPath)) {
}

const handleConfigChange = async () => {
// TODO: If there was a search string before it will be ignored here, needs fix
const [todoObjects, attributes, headers, filters] = await processDataRequest('');
if (todoObjects) {
mainWindow!.webContents.send('requestData', todoObjects, attributes, headers, filters);
try {
// TODO: If there was a search string before it will be ignored here, needs fix
const [todoObjects, attributes, headers, filters] = await processDataRequest('');
if (todoObjects) {
mainWindow!.webContents.send('requestData', todoObjects, attributes, headers, filters);
}
} catch(error) {
console.error(error);
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/main/modules/File/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ let stopAccessingSecurityScopedResource: any;

async function readFileContent(filePath: string, bookmark: string | null) {

if (filePath === null) {
throw new Error('No path has been passed');
if (!filePath) {
return null;
//throw new Error('No path has been passed');
}

if(bookmark) app.startAccessingSecurityScopedResource(bookmark)
Expand Down
3 changes: 3 additions & 0 deletions src/main/modules/ProcessDataRequest/ProcessDataRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const headers: Headers = {
async function processDataRequest(searchString: string): RequestedData[] {
const files: File[] = configStorage.get('files');
const activeFile: File | null = getActiveFile(files);

if(!activeFile) return []

const sorting: Sorting[] = configStorage.get('sorting');
const showHidden: boolean = configStorage.get('showHidden');
const fileSorting: boolean = configStorage.get('fileSorting');
Expand Down
Loading

0 comments on commit afcb74e

Please sign in to comment.