UNPKG

@hiki9/rich-domain

Version:

Rich Domain is a library that provides a set of tools to help you build complex business logic in NodeJS using Domain Driven Design principles.

89 lines 3.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AdapterToDomainError = exports.AdapterToPersistenceError = exports.UnknownError = exports.PrismaError = exports.UnknownConstraintViolation = exports.UniqueConstraintViolation = exports.NumericConstraintViolation = exports.LengthConstraintViolation = exports.NullConstraintViolation = exports.DuplicateEntry = exports.ForeignConstraintKey = exports.InvalidInput = exports.ItemNotFound = exports.ReadRepositoryError = exports.WriteRepositoryError = void 0; const _1 = require("./"); class WriteRepositoryError extends _1.RepositoryError { } exports.WriteRepositoryError = WriteRepositoryError; class ReadRepositoryError extends _1.RepositoryError { } exports.ReadRepositoryError = ReadRepositoryError; class ItemNotFound extends ReadRepositoryError { constructor(model, id) { super(`Não encontrei nenhum item('${model}') com o id fornecido ${id}.`); } } exports.ItemNotFound = ItemNotFound; class InvalidInput extends WriteRepositoryError { constructor(target, expected) { super(`Entrada inválida: ${target} deveria ser ${expected}`); } } exports.InvalidInput = InvalidInput; class ForeignConstraintKey extends WriteRepositoryError { constructor(table, constraint) { super(`Falha na FK constraint: ${table}.${constraint}`); } } exports.ForeignConstraintKey = ForeignConstraintKey; class DuplicateEntry extends WriteRepositoryError { constructor(target) { super(`Valor duplicado: ${target} já está registrado.`); } } exports.DuplicateEntry = DuplicateEntry; class NullConstraintViolation extends WriteRepositoryError { constructor(target) { super(`Valor não pode ser nulo: ${target}. ('Null constraint violation').`); } } exports.NullConstraintViolation = NullConstraintViolation; class LengthConstraintViolation extends WriteRepositoryError { constructor(target, max) { super(`Tamanho excedido. ${target} deve ter no máximo ${max}. ('Length constraint violation').`); } } exports.LengthConstraintViolation = LengthConstraintViolation; class NumericConstraintViolation extends WriteRepositoryError { constructor(target, min, max) { super(`Falha na validação numerica. ${target} deve está entre ${min} e ${max}. ('Numeric constraint violation').`); } } exports.NumericConstraintViolation = NumericConstraintViolation; class UniqueConstraintViolation extends WriteRepositoryError { constructor(target) { super(`Valor duplicado: ${target} deve ser único. ('Unique constraint violation').`); } } exports.UniqueConstraintViolation = UniqueConstraintViolation; class UnknownConstraintViolation extends WriteRepositoryError { constructor(err) { super(`Erro de constraint desconhecido: ${err}`); } } exports.UnknownConstraintViolation = UnknownConstraintViolation; class PrismaError extends WriteRepositoryError { constructor(err) { super(`Prisma error: ${err?.message}`); } } exports.PrismaError = PrismaError; class UnknownError extends WriteRepositoryError { constructor(err) { super(`Unknown error: ${err?.message}`); } } exports.UnknownError = UnknownError; class AdapterToPersistenceError extends WriteRepositoryError { constructor(err) { super(`Repository adapter to persistence error: ${err?.message}`, err); } } exports.AdapterToPersistenceError = AdapterToPersistenceError; class AdapterToDomainError extends WriteRepositoryError { constructor(err) { super(`Repository adapter to domain error: ${err?.message}`, err); } } exports.AdapterToDomainError = AdapterToDomainError; //# sourceMappingURL=repository-errors.js.map