presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftMetastoreApiStats.java/ThriftMetastoreApiStats/wrap
class ThriftMetastoreApiStats:    public <V> Callable<V> wrap(Callable<V> callable)
    {
        return () -> {
            try (TimeStat.BlockTimer ignored = time.time()) {
                return callable.call();
            }
            catch (Exception e) {
                if (e instanceof MetaException) {
                    metastoreExceptions.update(1);
                    // Need to throw here instead of falling through due to JDK-8059299
                    totalFailures.update(1);
                    throw e;
                }

                if (e instanceof TException) {
                    if (e instanceof TBase) {
                        // This exception is an API response and not a server error
                        throw e;
                    }

                    thriftExceptions.update(1);
                    // Need to throw here instead of falling through due to JDK-8059299
                    totalFailures.update(1);
                    throw e;
                }

                totalFailures.update(1);
                throw e;
            }
        };
    }