(fn, options = {})
| 80 | } |
| 81 | |
| 82 | export 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 | |
| 100 | export function wrapServiceClassMethods(ServiceClass, optionsFactory) { |
| 101 | const methodNames = Object.getOwnPropertyNames(ServiceClass) |
no test coverage detected