|
1 | 1 | //! Error and result types returned from the library functions.
|
2 | 2 |
|
3 |
| -use std::{error::Error as ErrorTrait, ffi::NulError, fmt::Display}; |
| 3 | +use std::{error::Error as ErrorTrait, ffi::NulError, fmt::Display, rc::Rc}; |
4 | 4 |
|
5 | 5 | use crate::php::{
|
6 | 6 | enums::DataType,
|
7 | 7 | exceptions::PhpException,
|
8 | 8 | flags::{ClassFlags, ZvalTypeFlags},
|
| 9 | + types::object::ZendObject, |
9 | 10 | };
|
10 | 11 |
|
11 | 12 | /// The main result type which is passed by the library.
|
12 | 13 | pub type Result<T> = std::result::Result<T, Error>;
|
13 | 14 |
|
14 | 15 | /// The main error type which is passed by the library inside the custom
|
15 | 16 | /// [`Result`] type.
|
16 |
| -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] |
| 17 | +#[derive(Debug, Clone)] |
17 | 18 | #[non_exhaustive]
|
18 | 19 | pub enum Error {
|
19 | 20 | /// An incorrect number of arguments was given to a PHP function.
|
@@ -50,6 +51,8 @@ pub enum Error {
|
50 | 51 | InvalidException(ClassFlags),
|
51 | 52 | /// Converting integer arguments resulted in an overflow.
|
52 | 53 | IntegerOverflow,
|
| 54 | + CompileFailed, |
| 55 | + UncaughtException(Rc<Box<ZendObject>>), |
53 | 56 | }
|
54 | 57 |
|
55 | 58 | impl Display for Error {
|
@@ -83,6 +86,8 @@ impl Display for Error {
|
83 | 86 | Error::IntegerOverflow => {
|
84 | 87 | write!(f, "Converting integer arguments resulted in an overflow.")
|
85 | 88 | }
|
| 89 | + Error::CompileFailed => write!(f, "Syntax error."), |
| 90 | + Error::UncaughtException(exception) => write!(f, "Uncaught Exception: {:?}", exception), |
86 | 91 | }
|
87 | 92 | }
|
88 | 93 | }
|
|
0 commit comments