Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 30 variants IncorrectArguments(usize, usize), ZvalConversion(DataType), UnknownFunctionType(u8), InvalidTypeToDatatype(ZvalTypeFlags), InvalidScope, InvalidPointer, DuplicateProperty { property: String, }, DuplicateMethod { method: String, }, DuplicateConstant { constant: String, }, DuplicateFunction { function: String, }, DuplicateClass { class: String, }, InvalidProperty { property: String, }, InvalidEnumCase { case: String, }, InvalidCString { position: usize, }, InvalidUtf8, Callable, Object, NotStringable(String), InvalidException(ClassFlags), IntegerOverflow, Catch(CatchError), ExceptionPending { class: String, }, StreamWrapperRegistrationFailure, StreamWrapperUnregistrationFailure, SapiWriteUnavailable, OutputHandlerStartFailed, ResponseHeaderFailed, SapiActivateUnderDl, LazyObjectFailed, AutoGlobalLoadFailed(&'static str),
}
Expand description

The main error type which is passed by the library inside the custom Result type.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IncorrectArguments(usize, usize)

An incorrect number of arguments was given to a PHP function.

The enum carries two integers - the first representing the number of arguments that were received, and the second representing the minimum number of arguments expected.

§

ZvalConversion(DataType)

There was an error converting a Zval into a primitive type.

The enum carries the data type of the Zval.

§

UnknownFunctionType(u8)

The function type read from the engine is not one this crate models.

The enum carries the raw value read from zend_function.type.

§

InvalidTypeToDatatype(ZvalTypeFlags)

Attempted to convert a ZvalTypeFlags struct to a DataType. The flags did not contain a datatype.

The enum carries the flags that were attempted to be converted to a DataType.

§

InvalidScope

The function called was called in an invalid scope (calling class-related functions inside of a non-class bound function).

§

InvalidPointer

The pointer inside a given type was invalid, either null or pointing to garbage.

§

DuplicateProperty

A class declared two properties with the same name, for example a #[php(prop)] field and a #[php(getter)] method.

Fields

§property: String

Class::$property that was declared twice.

§

DuplicateMethod

A class or enum declared two methods whose names differ only by ASCII case. PHP method names ignore case.

Fields

§method: String

Class::method that was declared twice.

§

DuplicateConstant

A class declared two constants, or an enum two cases, with the same name.

Fields

§constant: String

Class::CONSTANT that was declared twice.

§

DuplicateFunction

A module declared two functions whose names differ only by ASCII case.

Fields

§function: String

Name of the function that was declared twice.

§

DuplicateClass

A class, interface or enum with this name, ignoring ASCII case, is already registered with the engine.

Fields

§class: String

Name of the class that was registered twice.

§

InvalidProperty

The given property name does not exist.

Fields

§property: String

Name of the property that was looked up.

§

InvalidEnumCase

The enum has no case matching the given name or discriminant.

Fields

§case: String

Name or discriminant that was looked up.

§

InvalidCString

The string could not be converted into a C-string due to the presence of a NUL character.

Fields

§position: usize

Byte offset of the first NUL character.

§

InvalidUtf8

The string could not be converted into a valid Utf8 string

§

Callable

Could not call the given function.

§

Object

An object was expected.

§

NotStringable(String)

The object’s class does not implement __toString(), so it cannot be converted into a string.

The enum carries the name of the class.

§

InvalidException(ClassFlags)

An invalid exception type was thrown.

§

IntegerOverflow

Converting integer arguments resulted in an overflow.

§

Catch(CatchError)

The engine did not run a try_catch closure to completion.

§

ExceptionPending

A PHP exception is pending in the executor globals.

The exception is left where the engine put it, so it propagates on its own once control returns to PHP. Take ownership of it with ExecutorGlobals::take_exception to handle it from Rust.

The enum carries the class name of the pending exception.

Fields

§class: String

Class name of the pending exception.

§

StreamWrapperRegistrationFailure

A failure occurred while registering the stream wrapper

§

StreamWrapperUnregistrationFailure

A failure occurred while unregistering the stream wrapper

§

SapiWriteUnavailable

The SAPI write function is not available

§

OutputHandlerStartFailed

The engine refused to start an output handler: no request is active, or a registered conflict check rejected the handler name.

§

ResponseHeaderFailed

The engine refused to change the response headers: no request is active, a SapiGlobals guard is alive, or the header is invalid or comes after the headers were sent.

§

SapiActivateUnderDl

A module loaded with dl() has a sapi_activate_function. PHP unloads such a module at the end of the request, while the SAPI keeps the hook.

§

LazyObjectFailed

Failed to make an object lazy (PHP 8.4+)

§

AutoGlobalLoadFailed(&'static str)

The engine failed to load an auto-global.

The enum carries the name of the auto-global.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CatchError> for Error

Source§

fn from(source: CatchError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for PhpException

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<NulError> for Error

Source§

fn from(value: NulError) -> Self

Converts to this type from the input type.
Source§

impl From<TryFromIntError> for Error

Source§

fn from(_: TryFromIntError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.