"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepositoryNotFoundError = void 0;
const TypeORMError_1 = require("./TypeORMError");
const ObjectUtils_1 = require("../util/ObjectUtils");
const InstanceChecker_1 = require("../util/InstanceChecker");
/**
 * Thrown when repository for the given class is not found.
 */
class RepositoryNotFoundError extends TypeORMError_1.TypeORMError {
    constructor(connectionName, entityClass) {
        super();
        let targetName;
        if (InstanceChecker_1.InstanceChecker.isEntitySchema(entityClass)) {
            targetName = entityClass.options.name;
        }
        else if (typeof entityClass === "function") {
            targetName = entityClass.name;
        }
        else if (ObjectUtils_1.ObjectUtils.isObject(entityClass) && "name" in entityClass) {
            targetName = entityClass.name;
        }
        else {
            targetName = entityClass;
        }
        this.message = `No repository for "${targetName}" was found. Looks like this entity is not registered in ` +
            `current "${connectionName}" connection?`;
    }
}
exports.RepositoryNotFoundError = RepositoryNotFoundError;

//# sourceMappingURL=RepositoryNotFoundError.js.map
