TaskHub.Shared uses a standardized set of result codes to ensure consistency across all modules and services.
| Code | Constant | Meaning | Description |
|---|---|---|---|
| 0 | ResultCode.Success |
Success | The operation completed successfully. |
| 1 | ResultCode.Failed |
General Failure | A generic error occurred. |
While the core library only defines 0 and 1, the following conventions are recommended for application-specific implementations:
| Range | Category | Description |
|---|---|---|
| 100-199 | Validation | Errors related to input data validation. |
| 200-299 | Security | Authentication and authorization failures. |
| 300-399 | Persistence | Database errors, concurrency conflicts. |
| 400-499 | Domain | Business logic invariant violations. |
| 500+ | Infrastructure | Network timeouts, external service failures. |
It is recommended to use ResultFactory to create results with these codes:
// Success
return ResultFactory.Success();
// Failed with custom code
return ResultFactory.Failed("User not found", 404);