Handle integrity error exceptions.
437142
def handle_integrity_error(cls, exception):
        """"""

        m = re.match(cls.MYSQL_INSERT_ERROR_REGEX,
                     exception.statement)

        if not m:
            raise exception

        model = find_model_by_table_name(m.group('table'))

        if not model:
            raise exception

        m = re.match(cls.MYSQL_DUPLICATE_ENTRY_ERROR_REGEX,
                     exception.orig.args[1])

        if not m:
            raise exception

        entity = model.__name__
        eid = m.group('value')

        raise AlreadyExistsError(entity=entity, eid=eid)
689055
def error_handling(cls, fn):
        """"""
        def wrapper(*args, **kwargs):
            try:
                result = fn(*args, **kwargs)
                return result
            except InvalidRequestError as e:
                write_exception(e)

                if hasattr(e, 'request'):
                    write_error_message('request {0}'.format(repr(e.request)))
                if hasattr(e, 'response'):
                    write_error_message('response {0}'.format(repr(e.response)))

                raise e
        return wrapper
1221726
private void handleError() {
		String msg = I18nUtilities.format(UIContextHolder.getCurrent().getLocale(),
				InternalMessages.DEFAULT_CONTENT_ERROR);
		throw new ErrorCodeEscape(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
	}
926585
def handle_backend_error(self, exception):
        
        idp = self._load_idp_dynamic_entity_id(exception.state)
        return self._handle_backend_error(exception, idp)
773730
public function handleFatalError()
    {
        unset($this->_memoryReserve);
        
        $error = error_get_last();
        
        if (static::isFatalError($error)) {
            $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']);
            $this->exception = $exception;

            $this->logException($exception);
            
            /*
            if ($this->options['discard_output']) {
                $this->clearOutput();
            }
            
            $this->renderException($exception);
            */
            //debug_print_backtrace();
            
            exit(1);
        }
    }
28436
void handleException(Throwable t) {
    if (failure == null) {
      failure = t;

      for (ContextualFuture<?> responseFuture : responseFutures.values()) {
        responseFuture.context.executor().execute(() -> responseFuture.completeExceptionally(t));
      }
      responseFutures.clear();

      for (Listener<Throwable> listener : exceptionListeners) {
        listener.accept(t);
      }
    }
  }
759621
def _CaptureException(f, *args, **kwargs):
    """"""
    from ambry.dbexceptions import LoggedException

    b = args[0]  # The 'self' argument

    try:
        return f(*args, **kwargs)
    except Exception as e:
        raise
        try:
            b.set_error_state()
            b.commit()
        except Exception as e2:
            b.log('Failed to set bundle error state: {}'.format(e))
            raise e

        if b.capture_exceptions:
            b.logged_exception(e)
            raise LoggedException(e, b)
        else:
            b.exception(e)
            raise
1156485
protected void handleError(URI requestUri, HttpMethod requestMethod, int statusCode, String statusMessage,
            ByteSource errorBody) throws RestEndpointIOException {
        throw new RestEndpointException(requestUri, requestMethod, statusCode, statusMessage, errorBody);
    }
1188718
def handle_bail(self, bail):
        """"""
        self._add_error(_("Bailed: {reason}").format(reason=bail.reason))
268795
def handleError(exception, debugFlag=False, abortFlag=True):
    """"""
    if isinstance(exception, CmdError) or not debugFlag:
        error(str(exception))
    else:
        import traceback
        traceback.print_exc()
        error(str(exception))   # or log complete traceback as well?
    if abortFlag:
        sys.exit(1)
648792
def Exception(obj, eng, callbacks, exc_info):
        """"""
        exception_repr = ''.join(traceback.format_exception(*exc_info))
        msg = "Error:\n%s" % (exception_repr)
        eng.log.error(msg)
        if obj:
            # Sets an error message as a tuple (title, details)
            obj.extra_data['_error_msg'] = exception_repr
            obj.save(
                status=obj.known_statuses.ERROR,
                callback_pos=eng.state.callback_pos,
                id_workflow=eng.uuid
            )
        eng.save(WorkflowStatus.ERROR)
        db.session.commit()

        # Call super which will reraise
        super(InvenioTransitionAction, InvenioTransitionAction).Exception(
            obj, eng, callbacks, exc_info
        )
792659
def handle_error(_, client_addr):
        """"""
        exc_type, exc_value, _ = sys.exc_info()
        if exc_type is socket.error and exc_value[0] == 32:
            pass
        elif exc_type is cPickle.UnpicklingError:
            sys.stderr.write('Invalid connection from {0}\n'
                             .format(client_addr[0]))
        else:
            raise
11104
def _onError(self, message):
        """"""
        self.isOK = False
        if message.strip() != "":
            self.errors.append(message)
980397
def handle_error(error)
      return unless que_target

      max = resolve_que_setting(:maximum_retry_count)

      if max && error_count > max
        expire
      else
        retry_in_default_interval
      end
    end
710093
function handleError(type, filepath, opts, cb) {
  return function(err) {
    switch (type) {
      case 'read':
        if (err.code === 'ENOENT') {
          err.message = formatError('file does not exist', filepath, err);
        } else {
          err.message = formatError('cannot read file', filepath, err);
        }
        break;
      case 'write':
        if (!opts.overwrite && err.code === 'EEXIST') {
          return cb();
        }
        err.message = formatError('cannot write to', filepath, err);
        break;
    }
    cb(err);
  };
}
448026
private void runEKBErrorHooks(EKBCommit commit, EKBException exception) {
        if (exception != null) {
            for (EKBErrorHook hook : errorHooks) {
                hook.onError(commit, exception);
            }
            throw exception;
        }
    }
999437
void handleStorageException(final TSDB tsdb, final IncomingDataPoint dp, 
      final Exception e) {
    final StorageExceptionHandler handler = tsdb.getStorageExceptionHandler();
    if (handler != null) {
      handler.handleError(dp, e);
    }
  }