Skip to content

hotfix: Restrict Failure to non-success statuses only #9

Description

@IMustafaZeynali

Summary

Result.Failure(ResultStatus resultStatus, string? errorMessage = null) currently accepts any ResultStatus, including success statuses (Success, Created, NoContent). That contradicts the method name and intent.

Why

Callers can accidentally create a "failure" result that reports success (IsSuccess == true), which is confusing and error-prone.

Proposed change

  • Validate that resultStatus is a non-success status before creating the result
  • Throw a clear exception (or otherwise reject) when a success status is passed
  • Add/update unit tests for valid and invalid inputs

Context

Feedback from community code review.

Reported by
Thanks to Omid Rezaei Nejad for reporting this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:HightPriority: HightbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions