11'use strict' ; 
22
3+ const  errors  =  require ( 'internal/errors' ) ; 
34const  StringDecoder  =  require ( 'string_decoder' ) . StringDecoder ; 
45const  EventEmitter  =  require ( 'events' ) ; 
56const  net  =  require ( 'net' ) ; 
@@ -367,6 +368,7 @@ function onErrorNT(self, err) {
367368
368369
369370ChildProcess . prototype . kill  =  function ( sig )  { 
371+ 
370372  const  signal  =  sig  ===  0  ? sig  :
371373    convertToValidSignal ( sig  ===  undefined  ? 'SIGTERM'  : sig ) ; 
372374
@@ -538,15 +540,15 @@ function setupChannel(target, channel) {
538540      options  =  undefined ; 
539541    }  else  if  ( options  !==  undefined  && 
540542               ( options  ===  null  ||  typeof  options  !==  'object' ) )  { 
541-       throw  new  TypeError ( '" options" argument must be an object ' ) ; 
543+       throw  new  errors . TypeError ( 'ERR_INVALID_ARG_TYPE'  ,   ' options' ,   'Object ') ; 
542544    } 
543545
544546    options  =  Object . assign ( { swallowErrors : false } ,  options ) ; 
545547
546548    if  ( this . connected )  { 
547549      return  this . _send ( message ,  handle ,  options ,  callback ) ; 
548550    } 
549-     const  ex  =  new  Error ( 'channel closed ' ) ; 
551+     const  ex  =  new  errors . Error ( 'ERR_IPC_CHANNEL_CLOSED ' ) ; 
550552    if  ( typeof  callback  ===  'function' )  { 
551553      process . nextTick ( callback ,  ex ) ; 
552554    }  else  { 
@@ -559,7 +561,7 @@ function setupChannel(target, channel) {
559561    assert ( this . connected  ||  this . channel ) ; 
560562
561563    if  ( message  ===  undefined ) 
562-       throw  new  TypeError ( '"message" argument cannot be undefined ' ) ; 
564+       throw  new  errors . TypeError ( 'ERR_MISSING_ARGS'  ,   'message ') ; 
563565
564566    // Support legacy function signature 
565567    if  ( typeof  options  ===  'boolean' )  { 
@@ -586,7 +588,7 @@ function setupChannel(target, channel) {
586588      }  else  if  ( handle  instanceof  UDP )  { 
587589        message . type  =  'dgram.Native' ; 
588590      }  else  { 
589-         throw  new  TypeError ( 'This handle type can\'t be sent ' ) ; 
591+         throw  new  errors . TypeError ( 'ERR_INVALID_HANDLE_TYPE ' ) ; 
590592      } 
591593
592594      // Queue-up message and handle if we haven't received ACK yet. 
@@ -686,7 +688,7 @@ function setupChannel(target, channel) {
686688
687689  target . disconnect  =  function ( )  { 
688690    if  ( ! this . connected )  { 
689-       this . emit ( 'error' ,  new  Error ( 'IPC channel is already disconnected ' ) ) ; 
691+       this . emit ( 'error' ,  new  errors . Error ( 'ERR_IPC_DISCONNECTED ' ) ) ; 
690692      return ; 
691693    } 
692694
@@ -766,11 +768,12 @@ function _validateStdio(stdio, sync) {
766768      case  'ignore' : stdio  =  [ 'ignore' ,  'ignore' ,  'ignore' ] ;  break ; 
767769      case  'pipe' : stdio  =  [ 'pipe' ,  'pipe' ,  'pipe' ] ;  break ; 
768770      case  'inherit' : stdio  =  [ 0 ,  1 ,  2 ] ;  break ; 
769-       default : throw  new  TypeError ( 'Incorrect value of stdio option: '  +  stdio ) ; 
771+       default :
772+         throw  new  errors . TypeError ( 'ERR_INVALID_OPT_VALUE' ,  'stdio' ,  stdio ) ; 
770773    } 
771774  }  else  if  ( ! Array . isArray ( stdio ) )  { 
772-     throw  new  TypeError ( 'Incorrect value of stdio option: '    + 
773-         util . inspect ( stdio ) ) ; 
775+     throw  new  errors . TypeError ( 'ERR_INVALID_OPT_VALUE'  , 
776+                                 'stdio' ,   util . inspect ( stdio ) ) ; 
774777  } 
775778
776779  // At least 3 stdio will be created 
@@ -812,9 +815,9 @@ function _validateStdio(stdio, sync) {
812815        // Cleanup previously created pipes 
813816        cleanup ( ) ; 
814817        if  ( ! sync ) 
815-           throw  new  Error ( 'Child process can have only one IPC pipe ' ) ; 
818+           throw  new  errors . Error ( 'ERR_IPC_ONE_PIPE ' ) ; 
816819        else 
817-           throw  new  Error ( 'You cannot use IPC with synchronous forks ' ) ; 
820+           throw  new  errors . Error ( 'ERR_IPC_SYNC_FORK ' ) ; 
818821      } 
819822
820823      ipc  =  new  Pipe ( true ) ; 
@@ -849,15 +852,14 @@ function _validateStdio(stdio, sync) {
849852    }  else  if  ( isUint8Array ( stdio )  ||  typeof  stdio  ===  'string' )  { 
850853      if  ( ! sync )  { 
851854        cleanup ( ) ; 
852-         throw  new  TypeError ( 'Asynchronous forks do not support '  + 
853-                             'Buffer, Uint8Array or string input: '  + 
854-             util . inspect ( stdio ) ) ; 
855+         throw  new  errors . TypeError ( 'ERR_INVALID_SYNC_FORK_INPUT' , 
856+                                    util . inspect ( stdio ) ) ; 
855857      } 
856858    }  else  { 
857859      // Cleanup 
858860      cleanup ( ) ; 
859-       throw  new  TypeError ( 'Incorrect value for  stdio stream: '    + 
860-           util . inspect ( stdio ) ) ; 
861+       throw  new  errors . TypeError ( 'ERR_INVALID_OPT_VALUE'  ,   ' stdio' , 
862+                                   util . inspect ( stdio ) ) ; 
861863    } 
862864
863865    return  acc ; 
0 commit comments