Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: runtime/bin/stdio_patch.dart

Issue 2585443002: Error checking for Stdio calls (Closed)
Patch Set: Fix Windows Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/stdio_macos.cc ('k') | runtime/bin/stdio_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/stdio_patch.dart
diff --git a/runtime/bin/stdio_patch.dart b/runtime/bin/stdio_patch.dart
index 94781800738cda4a4c64e186ab857343a4b9499d..e537dc87212029c4cb756032c4949d545cdb1897 100644
--- a/runtime/bin/stdio_patch.dart
+++ b/runtime/bin/stdio_patch.dart
@@ -47,18 +47,47 @@
}
@patch class Stdin {
- @patch int readByteSync() native "Stdin_ReadByte";
+ @patch int readByteSync() {
+ var result = _readByte();
+ if (result is OSError) {
+ throw new StdinException("Error reading byte from stdin", result);
+ }
+ return result;
+ }
- @patch bool get echoMode => _echoMode;
- @patch void set echoMode(bool enabled) { _echoMode = enabled; }
+ @patch bool get echoMode {
+ var result = _echoMode();
+ if (result is OSError) {
+ throw new StdinException("Error getting terminal echo mode", result);
+ }
+ return result;
+ }
+ @patch void set echoMode(bool enabled) {
+ var result = _setEchoMode(enabled);
+ if (result is OSError) {
+ throw new StdinException("Error setting terminal echo mode", result);
+ }
+ }
- @patch bool get lineMode => _lineMode;
- @patch void set lineMode(bool enabled) { _lineMode = enabled; }
+ @patch bool get lineMode {
+ var result = _lineMode();
+ if (result is OSError) {
+ throw new StdinException("Error getting terminal line mode", result);
+ }
+ return result;
+ }
+ @patch void set lineMode(bool enabled) {
+ var result = _setLineMode(enabled);
+ if (result is OSError) {
+ throw new StdinException("Error setting terminal line mode", result);
+ }
+ }
- static bool get _echoMode native "Stdin_GetEchoMode";
- static void set _echoMode(bool enabled) native "Stdin_SetEchoMode";
- static bool get _lineMode native "Stdin_GetLineMode";
- static void set _lineMode(bool enabled) native "Stdin_SetLineMode";
+ static _echoMode() native "Stdin_GetEchoMode";
+ static _setEchoMode(bool enabled) native "Stdin_SetEchoMode";
+ static _lineMode() native "Stdin_GetLineMode";
+ static _setLineMode(bool enabled) native "Stdin_SetLineMode";
+ static _readByte() native "Stdin_ReadByte";
}
@patch class Stdout {
« no previous file with comments | « runtime/bin/stdio_macos.cc ('k') | runtime/bin/stdio_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698