Skip to content

Commit

Permalink
only catch CatchableError
Browse files Browse the repository at this point in the history
otherwise AssertionDefects can be caught!
  • Loading branch information
joachimschmidt557 committed Aug 18, 2024
1 parent ed3423f commit 720b718
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/nimmm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import lscolors

import core, scan, draw, external, nimboxext, keymap, readline

const
inotifyMask = IN_CREATE or IN_DELETE or IN_MOVED_FROM or IN_MOVED_TO

type
State = object of core.State
lsc: LsColors
Expand All @@ -28,7 +31,7 @@ proc safeSetCurDir(s: var State, path: Path) =

doAssert s.inotifyHandle.inotifyRmWatch(s.currentDirWatcher) >= 0
s.currentDirWatcher = s.inotifyHandle.inotifyAddWatch(os.getCurrentDir(),
IN_CREATE or IN_DELETE or IN_MOVED_FROM or IN_MOVED_TO)
inotifyMask)
doAssert s.currentDirWatcher >= 0

proc visible(entry: DirEntry, showHidden: bool, regex: Option[Regex]): bool =
Expand Down Expand Up @@ -111,13 +114,13 @@ proc right(s: var State) =
s.safeSetCurDir(Path(s.currentEntry.path))
s.resetTab()
s.rescan()
except:
except CatchableError:
s.error = ErrCannotCd
s.safeSetCurDir(prev)
elif s.currentEntry.info.kind == pcFile:
try:
openFile(s.currentEntry.path)
except:
except CatchableError:
s.error = ErrCannotOpen

proc mainLoop(nb: var Nimbox) =
Expand All @@ -138,7 +141,7 @@ proc mainLoop(nb: var Nimbox) =
s.inotifyHandle = inotifyInit()
doAssert s.inotifyHandle >= 0
s.currentDirWatcher = s.inotifyHandle.inotifyAddWatch(os.getCurrentDir(),
IN_CREATE or IN_DELETE or IN_MOVED_FROM or IN_MOVED_TO)
inotifyMask)
doAssert s.currentDirWatcher >= 0

defer:
Expand Down
2 changes: 1 addition & 1 deletion src/scan.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proc scan*(lsc: LsColors): tuple[entries: seq[DirEntry], error: bool] =
entries.add(DirEntry(path: path,
info: getFileInfo(path, false),
style: lsc.styleForPath(path)))
except:
except CatchableError:
error = true
entries.sort do (x, y: DirEntry) -> int:
cmpPaths(x.path, y.path)
Expand Down

0 comments on commit 720b718

Please sign in to comment.