UNPKG

node-web-mvc

Version:
33 lines (32 loc) 1.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Autowired_1 = __importDefault(require("../ioc/annotations/Autowired")); const AutowiredUtils_1 = require("../ioc/processor/AutowiredUtils"); const RuntimeAnnotation_1 = __importDefault(require("../servlets/annotations/annotation/RuntimeAnnotation")); const Exception_1 = __importDefault(require("./Exception")); class LoopDependenciesException extends Exception_1.default { constructor(creationChains) { super('LoopDependenciesException'); const chains = creationChains; const message = [ '\nThe dependencies of some of the beans in the application context form a cycle:\n', '┌─────┐', chains.map(({ beanName, definition }, i) => { const autowireds = RuntimeAnnotation_1.default.getAnnotations(Autowired_1.default, definition.clazz); const next = chains[i + 1] || chains[0]; const property = autowireds.find((m) => { const beanName = (0, AutowiredUtils_1.getBeanTypeByAnnotation)(m); return beanName == next.beanName; }); return `| ${beanName} (${definition.path} >>> ${definition.clazz.name}.${property === null || property === void 0 ? void 0 : property.name})`; }).join('\n↑ ↓\n'), '└─────┘', ].join('\n'); const stack = this.stack; this.stack = message + '\n ' + stack; } } exports.default = LoopDependenciesException;