Provides error handling for DeviceAdmin send_message and send_bulk_message methods.
979473
def send_messages(self, request, queryset, bulk=False):
		
		ret = []
		errors = []
		r = ""

		for device in queryset:
			try:
				if bulk:
					r = queryset.send_message("Test bulk notification")
				else:
					r = device.send_message("Test single notification")
				if r:
					ret.append(r)
			except GCMError as e:
				errors.append(str(e))
			except APNSServerError as e:
				errors.append(e.status)
			except WebPushError as e:
				errors.append(e.message)

			if bulk:
				break

		# Because NotRegistered and InvalidRegistration do not throw GCMError
		# catch them here to display error msg.
		if not bulk:
			for r in ret:
				if "error" in r["results"][0]:
					errors.append(r["results"][0]["error"])
		else:
			try:
				errors = [r["error"] for r in ret[0][0]["results"] if "error" in r]
			except TypeError:
				for entry in ret[0][0]:
					errors = errors + [r["error"] for r in entry["results"] if "error" in r]
			except IndexError:
				pass
		if errors:
			self.message_user(
				request, _("Some messages could not be processed: %r" % (", ".join(errors))),
				level=messages.ERROR
			)
		if ret:
			if bulk:
				# When the queryset exceeds the max_recipients value, the
				# send_message method returns a list of dicts, one per chunk
				try:
					success = ret[0][0]["success"]
				except TypeError:
					success = 0
					for entry in ret[0][0]:
						success = success + entry["success"]
				if success == 0:
					return
			elif len(errors) == len(ret):
				return
			if errors:
				msg = _("Some messages were sent: %s" % (ret))
			else:
				msg = _("All messages were sent: %s" % (ret))
			self.message_user(request, msg)
275442
def _handle_oss_error():
    
    try:
        yield

    except _OssError as exception:
        if exception.status in _ERROR_CODES:
            raise _ERROR_CODES[exception.status](
                exception.details.get('Message', ''))
        raise
163959
def compose_error_message(http_response, max_len=200)
        msg = http_response.body.gsub("\n", ' ')
        msg = "#{msg[0..max_len]} ..." if msg.size > max_len
        msg
      end
742879
function error(msg) {
  if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
    console.log('Error: ' + msg);
    console.log(backtrace());
  }
  UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
  throw new Error(msg);
}
23495
function onError (error) {
  switch (error.code) {
    case 'EACCES':
      throw new InternalServerError(error, 'Port require elevated privileges')
    case 'EADDRINUSE':
      throw new InternalServerError(error, 'Port is already in use')
    default:
      throw new InternalServerError(error, error.message)
  }
}
37060
def error_msg_callback(self, callback):
        """"""
        if callable(callback):
            self._error_msg_callback = callback
        else:
            self._error_msg_callback = None
1200346
def handle_message(self, msg):
        
        if msg.msg_id in self.messagesAllowed:
            super(LimitedReporter, self).handle_message(msg)
1218623
def _domain_event_device_removal_failed_cb(conn, domain, dev, opaque):
    '''
    
    '''
    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'dev': dev
    })
713567
private void handleError(final String errorMessage) {
		
		failed = true;
		
		switch (errorPolicy) {
		case LOG_ONLY:
			logger.error(errorMessage);
			break;
			
		case RUNTIME_EXCEPTION:
			throw new RuntimeException(errorMessage);

		default:
			logger.error("Got error {} but unkown error policy {}", errorMessage, errorPolicy);
			break;
		}
	}
1092476
async def on_raw_error(self, message):
        
        error = protocol.ServerError(' '.join(message.params))
        await self.on_data_error(error)
1337615
function handleError(err) {
  let errMsg = err;

  if (err instanceof Object) {
    errMsg = err.message || err.error || JSON.stringify(err);
  }

  printColumns(chalk.red('Error: ' + errMsg));
  printColumns(
    chalk.white(
      "If you can't settle this, please open an issue at:" + EOL + chalk.cyan(pkg.bugs.url)
    )
  );
  process.exit(1);
}
725367
def handle_resource_not_found(resource):
    
    resource.set_erred()
    resource.runtime_state = ''
    message = 'Does not exist at backend.'
    if message not in resource.error_message:
        if not resource.error_message:
            resource.error_message = message
        else:
            resource.error_message += ' (%s)' % message
    resource.save()
    logger.warning('%s %s (PK: %s) does not exist at backend.' % (
        resource.__class__.__name__, resource, resource.pk))
793339
def persistant_error(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
    
    add_message(request, ERROR_PERSISTENT, message, extra_tags=extra_tags,
                fail_silently=fail_silently, *args, **kwargs)
1221726
private void handleError() {
		String msg = I18nUtilities.format(UIContextHolder.getCurrent().getLocale(),
				InternalMessages.DEFAULT_CONTENT_ERROR);
		throw new ErrorCodeEscape(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
	}
1130939
def handle_error(self, error, req, schema, error_status_code, error_headers):
        
        status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS
        if status_code == 422:
            reason = "Unprocessable Entity"
        else:
            reason = None
        raise HTTPError(
            status_code,
            log_message=str(error.messages),
            reason=reason,
            messages=error.messages,
            headers=error_headers,
        )
1034800
function emitBadMessageError (message) {
    var error = new Error('invalid message')
    error.message = message
    client.emit('error', error)
  }
1195688
def _send_err(self, msg, errName, errMsg):
        
        r = message.ErrorMessage(
            errName,
            msg.serial,
            body=[errMsg],
            signature='s',
            destination=msg.sender,
        )

        self.conn.sendMessage(r)