UNPKG

@ydbjs/core

Version:

Core driver for YDB: manages connections, endpoint discovery, authentication, and service client creation. Foundation for all YDB client operations.

29 lines 852 B
import { loggers } from '@ydbjs/debug'; import { isAbortError } from 'abort-controller-x'; import { ClientError } from "nice-grpc"; let log = loggers.grpc; export const debug = async function* (call, options) { let hasError = false; try { return yield* call.next(call.request, options); } catch (error) { hasError = true; if (error instanceof ClientError) { log.log('%s', error.message); } else if (isAbortError(error)) { log.log('%s %s: %s', call.method.path, 'CANCELLED', error.message); } else { log.log('%s %s: %s', call.method.path, 'UNKNOWN', error); } throw error; } finally { if (!hasError) { log.log('%s %s', call.method.path, 'OK'); } } }; //# sourceMappingURL=middleware.js.map