Skip to main content

Auditing & Errors

Auditing

Most write operations accept an optional auditContext (and userContext) and use AuditService to create audit logs:

await auditService.createAuditLog({
tenantId,
action: AuditAction.FEATURE_UPDATED,
entity: 'Feature',
entityId: id,
dataBefore,
dataAfter,
performedBy,
ipAddress,
});

Audit actions are drawn from @prisma/access-control enums.

Error Handling

Services map data-layer errors to HTTP exceptions with friendly messages:

ExceptionUse Case
BadRequestExceptionInvalid input, state preconditions
ConflictExceptionDuplicate records
NotFoundExceptionResource not found
HttpException with INTERNAL_SERVER_ERRORUnknown errors

Feature uniqueness is validated before writes to avoid ambiguous conflicts.