@@ -45,17 +45,12 @@ pub var stderr = OutStream {
4545/// bug in the program that called the function.
4646error Invalid ;
4747
48- /// When an Unexpected error occurs, code that emitted the error likely needs
49- /// a patch to recognize the unexpected case so that it can handle it and emit
50- /// a more specific error.
51- error Unexpected ;
52-
5348error DiskQuota ;
5449error FileTooBig ;
5550error Io ;
5651error NoSpaceLeft ;
5752error BadPerm ;
58- error PipeFail ;
53+ error BrokenPipe ;
5954error BadFd ;
6055error IsDir ;
6156error NotDir ;
@@ -207,7 +202,10 @@ pub const OutStream = struct {
207202 if (self .handle ) | handle | return handle ;
208203 if (system .GetStdHandle (self .handle_id )) | handle | {
209204 if (handle == system .INVALID_HANDLE_VALUE ) {
210- return error .Unexpected ;
205+ const err = system .GetLastError ();
206+ return switch (err ) {
207+ else = > os .unexpectedErrorWindows (err ),
208+ };
211209 }
212210 self .handle = handle ;
213211 return handle ;
@@ -292,7 +290,7 @@ pub const InStream = struct {
292290 system .EFAULT = > unreachable ,
293291 system .EBADF = > return error .BadFd ,
294292 system .EIO = > return error .Io ,
295- else = > return error . Unexpected ,
293+ else = > return os . unexpectedErrorPosix ( read_err ) ,
296294 }
297295 }
298296 if (amt_read == 0 ) return index ;
@@ -309,12 +307,12 @@ pub const InStream = struct {
309307 const err = system .GetLastError ();
310308 return switch (err ) {
311309 system .ERROR .OPERATION_ABORTED = > continue ,
312- system .ERROR .BROKEN_PIPE = > error . PipeFail ,
313- else = > error . Unexpected ,
310+ system .ERROR .BROKEN_PIPE = > return index ,
311+ else = > os . unexpectedErrorWindows ( err ) ,
314312 };
315313 }
314+ if (amt_read == 0 ) return index ;
316315 index += amt_read ;
317- if (amt_read < want_read_count ) return index ;
318316 }
319317 return index ;
320318 } else {
@@ -374,7 +372,7 @@ pub const InStream = struct {
374372 system .EOVERFLOW = > error .Unseekable ,
375373 system .ESPIPE = > error .Unseekable ,
376374 system .ENXIO = > error .Unseekable ,
377- else = > error . Unexpected ,
375+ else = > os . unexpectedErrorPosix ( err ) ,
378376 };
379377 }
380378 },
@@ -394,7 +392,7 @@ pub const InStream = struct {
394392 system .EOVERFLOW = > error .Unseekable ,
395393 system .ESPIPE = > error .Unseekable ,
396394 system .ENXIO = > error .Unseekable ,
397- else = > error . Unexpected ,
395+ else = > os . unexpectedErrorPosix ( err ) ,
398396 };
399397 }
400398 },
@@ -414,7 +412,7 @@ pub const InStream = struct {
414412 system .EOVERFLOW = > error .Unseekable ,
415413 system .ESPIPE = > error .Unseekable ,
416414 system .ENXIO = > error .Unseekable ,
417- else = > error . Unexpected ,
415+ else = > os . unexpectedErrorPosix ( err ) ,
418416 };
419417 }
420418 return result ;
@@ -430,7 +428,7 @@ pub const InStream = struct {
430428 return switch (err ) {
431429 system .EBADF = > error .BadFd ,
432430 system .ENOMEM = > error .OutOfMemory ,
433- else = > error . Unexpected ,
431+ else = > os . unexpectedErrorPosix ( err ) ,
434432 }
435433 }
436434
@@ -485,7 +483,10 @@ pub const InStream = struct {
485483 if (self .handle ) | handle | return handle ;
486484 if (system .GetStdHandle (self .handle_id )) | handle | {
487485 if (handle == system .INVALID_HANDLE_VALUE ) {
488- return error .Unexpected ;
486+ const err = system .GetLastError ();
487+ return switch (err ) {
488+ else = > os .unexpectedErrorWindows (err ),
489+ };
489490 }
490491 self .handle = handle ;
491492 return handle ;
0 commit comments