www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Need help understanding exception...

reply sanjayss <dummy dummy.dummy> writes:
I got the following exception on a line of code that is basically 
"line = readln()" and need help in understanding what the 
exception is saying. (I am playing around with stdio prior to 
this using unix ioctls and maybe I am messing something up in the 
process resulting in this, but understanding the exception will 
give me a clue as to what I am doing wrong -- a basic D progam 
with readln() doesn't have the same issue). This is on linux with 
DMD version 2.07.

std.stdio.StdioException std/stdio.d(3969)
----------------
??:? void std.stdio.StdioException.opCall() [0x4c8891]
??:? ulong 
std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref 
char[], dchar, std.stdio.File.Orientation) [0x4c89e5]
/usr/include/dmd/phobos/std/stdio.d:1547 ulong 
std.stdio.File.readln!(char).readln(ref char[], dchar) [0x4acd95]
/usr/include/dmd/phobos/std/stdio.d:1408 immutable(char)[] 
std.stdio.File.readln!(immutable(char)[]).readln(dchar) [0x4acca2]
/usr/include/dmd/phobos/std/stdio.d:3377 immutable(char)[] 
std.stdio.readln!(immutable(char)[]).readln(dchar) [0x4acc2f]
telnetc.d:1572 void telnetc.handleEscapeMode(telnetc.TelnetInfo, 
ubyte) [0x4a6638]
telnetc.d:1591 void telnetc.handleKey(telnetc.TelnetInfo, ubyte) 
[0x4a6707]
telnetc.d:1603 void telnetc.handleKeyPress(telnetc.TelnetInfo, 
ubyte[]) [0x4a6788]
telnetc.d:1740 bool telnetc.readSocket!(void 
function(telnetc.TelnetInfo, ubyte[])*, 
telnetc.TelnetInfo).readSocket(immutable(char)[], 
std.socket.Socket, void function(telnetc.TelnetInfo, ubyte[])*, 
telnetc.TelnetInfo) [0x4adb18]
telnetc.d:1802 void 
telnetc.receiveAndProcessData(telnetc.TelnetInfo) [0x4a6f00]
telnetc.d:2165 _Dmain [0x4a7831]
??:? 
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv 
[0x4b9742]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).tryExec(scope void delegate()) [0x4b9680]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).runAll() [0x4b96fe]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).tryExec(scope void delegate()) [0x4b9680]
??:? _d_run_main [0x4b95dd]
??:? main [0x4b3827]
??:? __libc_start_main [0xf762ec4]
Feb 20 2016
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/20/2016 04:45 PM, sanjayss wrote:
 I got the following exception on a line of code that is basically "line
 = readln()" and need help in understanding what the exception is saying.
 (I am playing around with stdio prior to this using unix ioctls and
 maybe I am messing something up in the process resulting in this, but
 understanding the exception will give me a clue as to what I am doing
 wrong -- a basic D progam with readln() doesn't have the same issue).
 This is on linux with DMD version 2.07.

 std.stdio.StdioException std/stdio.d(3969)
 ----------------
 ??:? void std.stdio.StdioException.opCall() [0x4c8891]
 ??:? ulong std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref
 char[], dchar, std.stdio.File.Orientation) [0x4c89e5]
Judging frome the fact that the exception object does not contain a message, it must be coming from one of several of the following checks: if (ferror(fps)) StdioException(); For example: https://github.com/D-Programming-Language/phobos/blob/master/std/stdio.d#L4180 And the only meaning is that the input stream is in error state. :-/ Ali
Feb 20 2016
parent reply sanjayss <dummy dummy.dummy> writes:
On Sunday, 21 February 2016 at 01:06:16 UTC, Ali Çehreli wrote:
 On 02/20/2016 04:45 PM, sanjayss wrote:
 [...]
basically "line
 [...]
is saying.
 [...]
ioctls and
 [...]
this, but
 [...]
am doing
 [...]
issue).
 [...]
std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref
 [...]
Judging frome the fact that the exception object does not contain a message, it must be coming from one of several of the following checks: if (ferror(fps)) StdioException(); For example: https://github.com/D-Programming-Language/phobos/blob/master/std/stdio.d#L4180 And the only meaning is that the input stream is in error state. :-/ Ali
Thanks. That helps. I am making the stdin non-blocking (but reverting it back before doing the readln()) -- maybe that is causing some problems. Will follow this line of reasoning to see if I can figure out the problem.
Feb 20 2016
parent sanjayss <dummy dummy.dummy> writes:
On Sunday, 21 February 2016 at 06:24:54 UTC, sanjayss wrote:
 On Sunday, 21 February 2016 at 01:06:16 UTC, Ali Çehreli wrote:
 [...]
Thanks. That helps. I am making the stdin non-blocking (but reverting it back before doing the readln()) -- maybe that is causing some problems. Will follow this line of reasoning to see if I can figure out the problem.
Just doing a "stdin.clearerr()" after switching back from non-blocking mode helped. Thanks again.
Feb 20 2016