reject method

void reject(
  1. Map<String, dynamic> options
)

Reject the incoming Message Only valid for incoming Messages

Implementation

void reject(Map<String, dynamic> options) {
  int status_code = options['status_code'] ?? 480;
  String? reason_phrase = options['reason_phrase'];
  List<dynamic> extraHeaders = Utils.cloneArray(options['extraHeaders']);
  String? body = options['body'];

  if (_direction != 'incoming') {
    throw Exceptions.NotSupportedError(
        '"reject" not supported for outgoing Message');
  }

  if (_is_replied != null) {
    throw AssertionError('incoming Message already replied');
  }

  if (status_code < 300 || status_code >= 700) {
    throw Exceptions.TypeError('Invalid status_code: $status_code');
  }

  _is_replied = true;
  _request.reply(status_code, reason_phrase, extraHeaders, body);
}