packages/grpc-native-core/src/server.js
function handleError(call, error) {
  var statusMetadata = new Metadata();
  var status = {
    code: constants.status.UNKNOWN,
    details: 'Unknown Error'
  };
  if (error.hasOwnProperty('message')) {
    status.details = error.message;
  }
  if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
    status.code = error.code;
    if (error.hasOwnProperty('details')) {
      status.details = error.details;
    }
  }
  if (error.hasOwnProperty('metadata')) {
    statusMetadata = error.metadata;
  }
  status.metadata = statusMetadata._getCoreRepresentation();
  var error_batch = {};
  if (!call.metadataSent) {
    error_batch[grpc.opType.SEND_INITIAL_METADATA] =
        (new Metadata())._getCoreRepresentation();
  }
  error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
  call.startBatch(error_batch, function(){});
}
function handleError(call, error) {
  var statusMetadata = new Metadata();
  var status = {
    code: constants.status.UNKNOWN,
    details: 'Unknown Error'
  };
  if (error.hasOwnProperty('message')) {
    status.details = error.message;
  }
  if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
    status.code = error.code;
    if (error.hasOwnProperty('details')) {
      status.details = error.details;
    }
  }
  if (error.hasOwnProperty('metadata')) {
    statusMetadata = error.metadata;
  }
  status.metadata = statusMetadata._getCoreRepresentation();
  var error_batch = {};
  if (!call.metadataSent) {
    error_batch[grpc.opType.SEND_INITIAL_METADATA] =
        (new Metadata())._getCoreRepresentation();
  }
  error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
  call.startBatch(error_batch, function(){});
}
function handleError ( call , error ) { var statusMetadata = new Metadata ( ) ; var status = { code : constants . status . UNKNOWN , details : 'Unknown Error' } ; if ( error . hasOwnProperty ( 'message' ) ) { status . details = error . message ; } if ( error . hasOwnProperty ( 'code' ) && Number . isInteger ( error . code ) ) { status . code = error . code ; if ( error . hasOwnProperty ( 'details' ) ) { status . details = error . details ; } } if ( error . hasOwnProperty ( 'metadata' ) ) { statusMetadata = error . metadata ; } status . metadata = statusMetadata . _getCoreRepresentation ( ) ; var error_batch = { } ; if ( ! call . metadataSent ) { error_batch [ grpc . opType . SEND_INITIAL_METADATA ] = ( new Metadata ( ) ) . _getCoreRepresentation ( ) ; } error_batch [ grpc . opType . SEND_STATUS_FROM_SERVER ] = status ; call . startBatch ( error_batch , function ( ) { } ) ; }
Handle an error on a call by sending it as a status
@private
@param {grpc.internal~Call} call The call to send the error on
@param {(Object|Error)} error The error object
Handle an error on a call by sending it as a status