Files
admin/_docs/02_document/modules/common_business_exception.md
T
Oleksandr Bezdieniezhnykh 3a925b9b0f
ci/woodpecker/push/01-test Pipeline failed
ci/woodpecker/push/02-build-push unknown status
refactor: remove obsolete resource download and installer endpoints
- Deleted the `POST /resources/get/{dataFolder?}` and `GET /resources/get-installer` endpoints as part of the architectural shift towards simplified resource management.
- Removed associated methods and configurations, including `ResourcesService.GetEncryptedResource`, `ResourcesService.GetInstaller`, and related properties in `ResourcesConfig`.
- Cleaned up environment variables and configuration files to reflect the removal of installer-related settings.
- Eliminated the `GetResourceRequest` DTO and its validator, along with the `WrongResourceName` error code.
- Updated documentation to clarify the changes in resource handling and the retirement of per-user file encryption.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-14 04:17:55 +03:00

2.7 KiB

Module: Azaion.Common.BusinessException

Purpose

Custom exception type for domain-level errors, paired with an ExceptionEnum catalog of all business error codes.

Public Interface

BusinessException

Member Signature Description
Constructor BusinessException(ExceptionEnum exEnum) Creates exception with message from ExceptionEnum's [Description] attribute
ExceptionEnum ExceptionEnum ExceptionEnum { get; set; } The specific error code
GetMessage static string GetMessage(ExceptionEnum exEnum) Looks up human-readable message for an error code

ExceptionEnum

Value Code Description
NoEmailFound 10 No such email found
EmailExists 20 Email already exists
WrongPassword 30 Passwords do not match
PasswordLengthIncorrect 32 Password should be at least 12 characters (description text — actual validator threshold is 8 chars per RegisterUserValidator)
EmailLengthIncorrect 35 Email is empty or invalid
WrongEmail 37 (no description attribute)
UserDisabled 38 User account is disabled
NoFileProvided 60 No file provided

Cycle 1 (2026-05-13) noteHardwareIdMismatch = 40 and BadHardware = 45 were removed by AZ-197 (admin-side hardware-binding cleanup). Codes 40 and 45 should NOT be reused for a different meaning — older clients may still surface "Hardware mismatch" UX strings keyed on the integer. UserDisabled = 38 was added earlier (still part of the baseline). See _docs/03_implementation/batch_06_report.md.

Cycle 2 (2026-05-14) noteWrongResourceName = 50 was removed along with the GetResourceRequest validator (the only consumer). Code 50 should NOT be reused — gap kept per the cycle-1 lesson on retired numeric codes.

Internal Logic

Static constructor eagerly loads all ExceptionEnum descriptions into a dictionary via EnumExtensions.GetDescriptions<ExceptionEnum>(). Messages are retrieved by dictionary lookup with fallback to ToString().

Dependencies

  • EnumExtensions — for GetDescriptions<T>()

Consumers

  • BusinessExceptionHandler — catches and serializes to HTTP 409 response
  • UserService — throws for email/password validation failures (NoEmailFound, WrongPassword, EmailExists, UserDisabled)
  • ResourcesService — throws NoFileProvided for missing file uploads
  • FluentValidation validators — reference ExceptionEnum codes in .WithErrorCode()

Data Models

None.

Configuration

None.

External Integrations

None.

Security

Error codes are returned to the client via BusinessExceptionHandler. Codes are numeric and messages are user-facing.

Tests

None.