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 Sun, Nov 17, 00:43
Reviewer
dereckson
Differential Revision
D1656: Introduce Result class with Ok and Err types for status handling
Parents
rKOT6a9d07fcfe0e: Allow to manipulate time ranges and check overlaps
Branches
Unknown
Tags
Unknown