MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / wrapServiceBoundary

Function wrapServiceBoundary

src/utils/serviceErrorBoundary.js:82–98  ·  view source on GitHub ↗
(fn, options = {})

Source from the content-addressed store, hash-verified

80}
81
82export function wrapServiceBoundary(fn, options = {}) {
83 return function wrappedServiceBoundary(...args) {
84 try {
85 const result = fn.apply(this, args);
86
87 if (result && typeof result.then === 'function') {
88 return result.catch((error) => {
89 throw ensureTypedServiceError(error, typeof options === 'function' ? options(...args) : options);
90 });
91 }
92
93 return result;
94 } catch (error) {
95 throw ensureTypedServiceError(error, typeof options === 'function' ? options(...args) : options);
96 }
97 };
98}
99
100export function wrapServiceClassMethods(ServiceClass, optionsFactory) {
101 const methodNames = Object.getOwnPropertyNames(ServiceClass)

Callers 2

guildConfig.jsFile · 0.90
wrapServiceClassMethodsFunction · 0.85

Calls 1

ensureTypedServiceErrorFunction · 0.85

Tested by

no test coverage detected