mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-12-15 02:17:02 +01:00
Format
This commit is contained in:
parent
94fb7c78a1
commit
8d6850afd0
@ -8,7 +8,8 @@ use crate::{
|
|||||||
ffi::zend_throw_exception_ex,
|
ffi::zend_throw_exception_ex,
|
||||||
ffi::zend_throw_exception_object,
|
ffi::zend_throw_exception_object,
|
||||||
flags::ClassFlags,
|
flags::ClassFlags,
|
||||||
zend::{ce, ClassEntry}, types::Zval,
|
types::Zval,
|
||||||
|
zend::{ce, ClassEntry},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Result type with the error variant as a [`PhpException`].
|
/// Result type with the error variant as a [`PhpException`].
|
||||||
@ -38,7 +39,12 @@ impl PhpException {
|
|||||||
/// * `code` - Integer code to go inside the exception.
|
/// * `code` - Integer code to go inside the exception.
|
||||||
/// * `ex` - Exception type to throw.
|
/// * `ex` - Exception type to throw.
|
||||||
pub fn new(message: String, code: i32, ex: &'static ClassEntry) -> Self {
|
pub fn new(message: String, code: i32, ex: &'static ClassEntry) -> Self {
|
||||||
Self { message, code, ex, object: None, }
|
Self {
|
||||||
|
message,
|
||||||
|
code,
|
||||||
|
ex,
|
||||||
|
object: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new default exception instance, using the default PHP
|
/// Creates a new default exception instance, using the default PHP
|
||||||
@ -77,9 +83,7 @@ impl PhpException {
|
|||||||
/// and an error otherwise.
|
/// and an error otherwise.
|
||||||
pub fn throw(self) -> Result<()> {
|
pub fn throw(self) -> Result<()> {
|
||||||
match self.object {
|
match self.object {
|
||||||
Some(object) => {
|
Some(object) => throw_object(object),
|
||||||
throw_object(object)
|
|
||||||
},
|
|
||||||
None => throw_with_code(self.ex, self.code, &self.message),
|
None => throw_with_code(self.ex, self.code, &self.message),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +170,6 @@ pub fn throw_with_code(ex: &ClassEntry, code: i32, message: &str) -> Result<()>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Throws an exception object.
|
/// Throws an exception object.
|
||||||
///
|
///
|
||||||
/// Returns a result containing nothing if the exception was successfully
|
/// Returns a result containing nothing if the exception was successfully
|
||||||
|
Loading…
Reference in New Issue
Block a user