Skip to content

Commit

Permalink
Simplify exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
torhus committed Nov 30, 2022
1 parent 8a8c601 commit a369b27
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/servertable.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module servertable;

import std.ascii : newline;
import std.conv;
import std.exception : ifThrown;
import std.math;
import std.range;
import std.string;
Expand Down Expand Up @@ -114,17 +115,13 @@ class ServerTable
}

// restore sort order from previous session
int sortCol = 0;
int sortCol;
bool reversed = false;
try {
string s = getSessionState("serverSortOrder");
sortCol = parse!int(s);
reversed = s.startsWith('r');
if (sortCol >= serverHeaders.length)
sortCol = 0;

}
catch (ConvException) { }
string s = getSessionState("serverSortOrder");
sortCol = parse!int(s).ifThrown!ConvException(1);
reversed = s.startsWith('r');
if (sortCol >= serverHeaders.length)
sortCol = 0;

table_.setSortColumn(table_.getColumn(sortCol));
table_.setSortDirection(reversed ? SWT.DOWN : SWT.UP);
Expand Down

0 comments on commit a369b27

Please sign in to comment.