Helper function to construct exception for parquet schema mismatch.
971701
private SchemaColumnConvertNotSupportedException constructConvertNotSupportedException(
      ColumnDescriptor descriptor,
      WritableColumnVector column) {
    return new SchemaColumnConvertNotSupportedException(
      Arrays.toString(descriptor.getPath()),
      descriptor.getPrimitiveType().getPrimitiveTypeName().toString(),
      column.dataType().catalogString());
  }
308892
def translate_exception(exc, kwargs):
    
    error = exc.response['Error']
    error.setdefault('Message', '')
    err_class = EXC.get(error['Code'], DynamoDBError)
    return err_class(exc.response['ResponseMetadata']['HTTPStatusCode'],
                     exc_info=sys.exc_info(), args=pformat(kwargs), **error)
482417
def _catch(f, exception_type):
  """"""
  if not (inspect.isclass(exception_type)
          and issubclass(exception_type, Exception)):
    exception_type = Exception

  @functools.wraps(f)
  def wrap(*args, **kw):
    try:
      return f(*args, **kw)
    except exception_type as e:  # pylint: disable=broad-except
      qj(e, 'Caught an exception in %s' % f, d=1, _depth=2)
  return wrap
987220
function exceptionWithHostPort(err, syscall, address, port, additional) {
  // TODO(joyeecheung): We have to use the type-checked
  // getSystemErrorName(err) to guard against invalid arguments from users.
  // This can be replaced with [ code ] = errmap.get(err) when this method
  // is no longer exposed to user land.
  if (util === undefined) util = require('util');
  const code = util.getSystemErrorName(err);
  let details = '';
  if (port && port > 0) {
    details = ` ${address}:${port}`;
  } else if (address) {
    details = ` ${address}`;
  }
  if (additional) {
    details += ` - Local (${additional})`;
  }

  // eslint-disable-next-line no-restricted-syntax
  const ex = new Error(`${syscall} ${code}${details}`);
  // TODO(joyeecheung): errno is supposed to err, like in uvException
  ex.code = ex.errno = code;
  ex.syscall = syscall;
  ex.address = address;
  if (port) {
    ex.port = port;
  }

  Error.captureStackTrace(ex, exceptionWithHostPort);
  return ex;
}
883302
MolgenisValidationException translateDependentObjectsStillExist(PSQLException pSqlException) {
    ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
    String detail = serverErrorMessage.getDetail();
    Matcher matcher =
        Pattern.compile(
                "constraint (.+) on table \"?([^\"]+)\"? depends on table \"?([^\"]+)\"?\n?")
            .matcher(detail);

    Map<String, Set<String>> entityTypeDependencyMap = new LinkedHashMap<>();
    while (matcher.find()) {
      String tableName = matcher.group(2);
      String dependentTableName = matcher.group(3);

      String entityTypeName = tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN);
      String dependentEntityTypeName =
          tryGetEntityTypeName(dependentTableName).orElse(TOKEN_UNKNOWN);
      Set<String> dependentTableNames =
          entityTypeDependencyMap.computeIfAbsent(
              dependentEntityTypeName, k -> new LinkedHashSet<>());
      dependentTableNames.add(entityTypeName);
    }

    if (entityTypeDependencyMap.isEmpty()) // no matches
    {
      LOG.error(ERROR_TRANSLATING_POSTGRES_EXC_MSG, pSqlException);
      throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException);
    }

    Set<ConstraintViolation> constraintViolations =
        entityTypeDependencyMap
            .entrySet()
            .stream()
            .map(
                entry -> {
                  String message;
                  if (entry.getValue().size() == 1) {
                    message =
                        format(
                            "Cannot delete entity '%s' because entity '%s' depends on it.",
                            entry.getKey(), entry.getValue().iterator().next());
                  } else {
                    message =
                        format(
                            "Cannot delete entity '%s' because entities '%s' depend on it.",
                            entry.getKey(), entry.getValue().stream().collect(joining(", ")));
                  }
                  return new ConstraintViolation(message, null);
                })
            .collect(toCollection(LinkedHashSet::new));

    return new MolgenisValidationException(constraintViolations);
  }
706395
def p_Exception(p):
  
  p[0] = model.Exception(name=p[2], parent=p[3], members=p[5])
994562
public Schema handle(int version, Route route, Properties parms, String post_body) throws Exception {
    Class<? extends Schema> handler_schema_class = getHandlerMethodInputSchema(route._handler_method);
    Schema schema = Schema.newInstance(handler_schema_class);

    // If the schema has a real backing class fill from it to get the default field values:
    Class<? extends Iced> iced_class = schema.getImplClass();
    if (iced_class != Iced.class) {
      Iced defaults = schema.createImpl();
      schema.fillFromImpl(defaults);
    }

    boolean has_body = (null != post_body);

    // Fill from http request params:
    schema = schema.fillFromParms(parms, !has_body);
    if (schema == null)
      throw H2O.fail("fillFromParms returned a null schema for version: " + version + " in: " + this.getClass() + " with params: " + parms);

    //Fill from JSON body, if there is one.  NOTE: there should *either* be a JSON body *or* parms,
    //with the exception of control-type query parameters.
    if (has_body) {
      schema = schema.fillFromBody(post_body);
    }

    // NOTE! The handler method is free to modify the input schema and hand it back.
    Schema result = null;
    try {
      route._handler_method.setAccessible(true);
      result = (Schema)route._handler_method.invoke(this, version, schema);
    }
    // Exception thrown out of the invoked method turn into InvocationTargetException
    // rather uselessly.  Peel out the original exception & throw it.
    catch( InvocationTargetException ite ) {
      Throwable t = ite.getCause();
      if( t instanceof RuntimeException ) throw (RuntimeException)t;
      if( t instanceof Error ) throw (Error)t;
      throw new RuntimeException(t);
    }

    // Version-specific unwind from the Iced back into the Schema
    return result;
  }
662667
private void throwSaxException(Exception src)
        throws SAXException
    {
        SAXParseException se = new SAXParseException(src.getMessage(), /*(Locator)*/ this, src);
        ExceptionUtil.setInitCause(se, src);
        if (mErrorHandler != null) {
            mErrorHandler.fatalError(se);
        }
        throw se;
    }
503232
private Schema handle( Request.RequestType type, Method meth, int version, Properties parms ) throws Exception {
    Schema S;
    switch( type ) {
    // case html: // These request-types only dictate the response-type;
    case java: // the normal action is always done.
    case json:
    case xml: {
      Class x = meth.getDeclaringClass();
      Class<Handler> clz = (Class<Handler>)x;
      Handler h = clz.newInstance();
      return h.handle(version,meth,parms); // Can throw any Exception the handler throws
    }
    case query:
    case help:
    default:
      throw H2O.unimpl();
    }
  }
246248
def exception(self, s):
        """"""
        self.error(s)
        type, value, tb = sys.exc_info()
        self.writelines(traceback.format_stack(), 1)
        self.writelines(traceback.format_tb(tb)[1:], 1)
        self.writelines(traceback.format_exception_only(type, value), 1)
267707
function encodeMetadataException(type) {
	if (type === "metadata") {
		return exceptions.METADATA;
	} else if (type === "access") {
		return exceptions.ACCESS;
	} else if (type === "credits") {
		return exceptions.CREDITS;
	} else if (type === "conflictingSession") {
		return exceptions.CONFLICTING_SESSION;
	} else if (type === "items") {
		return exceptions.ITEMS;
	} else if (type === "schema") {
		return exceptions.SCHEMA;
	} else if (type === "notification") {
		return exceptions.NOTIFICATION;
	} else {
		return exceptions.GENERIC;
	}
}
398214
def exception(self, *args, **kwargs):
        """"""
        kwargs['api'] = self.api
        return exception(*args, **kwargs)
1302319
public static void throwIfRequestingUnsupportedFeatures(HColumnDescriptor columnDescriptor) {
    Map<String, String> unsupportedConfiguration = getUnsupportedFeatures(columnDescriptor);
    if (!unsupportedConfiguration.isEmpty()) {
      List<String> configurationStrings = new ArrayList<String>(unsupportedConfiguration.size());
      for (Map.Entry<String, String> entry : unsupportedConfiguration.entrySet()) {
        configurationStrings.add(String.format("(%s: %s)", entry.getKey(), entry.getValue()));
      }

      String exceptionMessage = String.format(
          "Unsupported configuration options: %s",
          Joiner.on(",").join(configurationStrings));
      throw new UnsupportedOperationException(exceptionMessage);
    }
  }
192256
private static boolean mySqlErrorCodeMatches(Exception e, int errorCode)
    {
        return Throwables.getCausalChain(e).stream()
                .filter(SQLException.class::isInstance)
                .map(SQLException.class::cast)
                .filter(t -> t.getErrorCode() == errorCode)
                .map(Throwable::getStackTrace)
                .anyMatch(isMySQLException());
    }
783870
def fire_exception(exc, opts, job=None, node='minion'):
    '''
    
    '''
    if job is None:
        job = {}
    event = salt.utils.event.SaltEvent(node, opts=opts, listen=False)
    event.fire_event(pack_exception(exc), '_salt_error')
860106
private static void handleSQLException(SQLException e, String poolName, String sql) {

    YankSQLException yankSQLException = new YankSQLException(e, poolName, sql);

    if (throwWrappedExceptions) {
      throw yankSQLException;
    } else {
      logger.error(yankSQLException.getMessage(), yankSQLException);
    }
  }
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
        )