Skip to content

Commit

Permalink
refactor: added exception names to try blocks
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 42c40966741544059d0ab7aa960625db70c616b216d32778bed32545de0d3af0
  • Loading branch information
thindil committed Apr 30, 2024
1 parent b5ba058 commit a68597a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/input.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
# Standard library imports
import std/[parseopt, strutils, terminal, unicode]
# External modules imports
import contracts, nancy, termstyle
import ansiparse, contracts, nancy, termstyle
import norm/sqlite
import norm/private/log
# Internal imports
import constants, output, theme, types

Expand Down Expand Up @@ -229,7 +230,7 @@ proc readInput*(maxLength: MaxInputLength = maxInputLength;
else:
moveCursor(inputChar = inputChar, cursorPosition = cursorPosition,
inputString = resultString, db = db)
except:
except EOFError, IOError, ValueError:
showError(message = "Can't get the next character after Escape. Reason: ",
e = getCurrentException(), db = db)
return exitString
Expand Down Expand Up @@ -363,7 +364,8 @@ proc askForName*[T](db; action: OutputMessage; namesType: string;
row = ["", "", "", ""]
rowIndex = 0
table.add(parts = row)
except:
except UnknownEscapeError, FinalByteError, InsufficientInputError, DbError,
LoggingError, ValueError:
showError(message = "Can't show the list of " & namesType & "s. Reason: ",
e = getCurrentException(), db = db)
when names is seq[Completion]:
Expand All @@ -375,7 +377,7 @@ proc askForName*[T](db; action: OutputMessage; namesType: string;
return
try:
table.echoTable
except:
except IOError, Exception:
showError(message = "Can't show the list of " & namesType & "s. Reason: ",
e = getCurrentException(), db = db)
return
Expand All @@ -393,7 +395,7 @@ proc askForName*[T](db; action: OutputMessage; namesType: string;
return
try:
name = names[parseInt(s = $id) - 1]
except:
except ValueError:
when names is seq[Completion]:
name.command = ""
elif names is seq[Plugin]:
Expand Down

0 comments on commit a68597a

Please sign in to comment.