Skip to content

Commit

Permalink
Avoid throwing an exception for hasTerminal
Browse files Browse the repository at this point in the history
See dart-lang/test#1261

Throwing and immediately catching an exception has negative implications
for debugging and pausing on thrown exceptions. The exception is not
needed provided we duplicate a small bit of knowledge - that the
function to retrieve terminal size would return a non-list.

Change-Id: Ic92f7c0480d58963e857c699aa0251eedeb3e627
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152922
Commit-Queue: Nate Bosch <[email protected]>
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Zichang Guo <[email protected]>
  • Loading branch information
natebosch authored and [email protected] committed Jun 30, 2020
1 parent c0a7ee9 commit d64cf16
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions sdk/lib/_internal/vm/bin/stdio_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,7 @@ class Stdin {
@patch
class Stdout {
@patch
bool _hasTerminal(int fd) {
try {
_terminalSize(fd);
return true;
} catch (_) {
return false;
}
}

bool _hasTerminal(int fd) => _getTerminalSize(fd) is List;
@patch
int _terminalColumns(int fd) => _terminalSize(fd)[0];
@patch
Expand Down

0 comments on commit d64cf16

Please sign in to comment.