HomeDevCentral

Introduce Result class with Ok and Err types for status handling

Description

Introduce Result class with Ok and Err types for status handling

Summary:
This change adds a Result class to improve error and success handling.

Inspired by Rust generic type Result, this approach allows functions to return
either an Ok type for successful outcomes or an Err type for errors.

In PHP, where generics and enums are not natively available, Result serves
as a base class with two implementations:

  • Err for exceptions
  • Ok for successful values

This pattern provides a more structured and readable way to handle
results and errors explicitly compared to traditional exception handling.

Reference:
https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html

Test Plan: Implement in Zed story engine

Reviewers: dereckson

Reviewed By: dereckson

Differential Revision: https://devcentral.nasqueron.org/D1656

Details

Provenance
derecksonAuthored on Sep 2 2018, 00:02
derecksonPushed on Nov 11 2024, 15:17
Reviewer
dereckson
Differential Revision
D1656: Introduce Result class with Ok and Err types for status handling
Parents
rKERUALDc3fe233eeb0b: Print triggered deprecations, errors, notices, warnings running tests
Branches
Unknown
Tags
Unknown