Home
DevCentral
Search
Configure Global Search
Log In
Transactions
D1656
Change Details
Change Details
Old
New
Diff
When a library needs to communicate an error status, to be handled only by an initial caller down in the task or a success, the Result generic type from the Rust library is convenient. If PHP doesn't have the generics and Rust-like enum, we can at least provide a base class Result, with two concrete implementations: - Err for exceptions - Ok for actual values Reference: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
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 errors or 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
When a library needs to communicate an
This change adds a Result class to improve
error
status, to be
and success
handl
ed only by an initial caller down in the task or a success
ing. Inspired by Rust generic type Result
,
the Result
this approach allows functions to return
generic
either an Ok
type f
rom the Rust library is convenient
or successful outcomes or an Err type for errors
.
If
In
PHP
doesn't have th
, wher
e generics and
Rust-like enum
enums are not natively available
,
we can at least
Result serves
provide
as
a base cla
ss Result,
ss
with tw
o concrete
o
implementations: - Err for
errors or
exceptions - Ok for
actual values
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
Continue