pub fn throw_with_code(ex: &ClassEntry, code: i32, message: &str) -> Result<()> {
    let flags = ex.flags();

    // Can't throw an interface or abstract class.
    if flags.contains(ClassFlags::Interface) || flags.contains(ClassFlags::Abstract) {
        return Err(Error::InvalidException(flags));
    }

    // SAFETY: We are given a reference to a `ClassEntry` therefore when we cast it
    // to a pointer it will be valid.
    unsafe {
        zend_throw_exception_ex(
            ptr::from_ref(ex).cast_mut(),
            code.into(),
            CString::new("%s")?.as_ptr(),
            CString::new(message)?.as_ptr(),
        )
    };
    Ok(())
}
Throws an exception with a given message and status code. See [`ClassEntry`]
for some built-in exception types.

Returns a result containing nothing if the exception was successfully
thrown.

# Parameters

* `ex` - The exception type to throw.
* `code` - The status code to use when throwing the exception.
* `message` - The message to display when throwing the exception.

# Errors

* [`Error::InvalidException`] - If the exception type is an interface or
abstract class.
* If the message contains NUL bytes.

# Examples

```no_run
use ext_php_rs::{zend::{ce, ClassEntry}, exception::throw_with_code};

throw_with_code(ce::compile_error(), 123, "This is a CompileError.");
```
src/exception.rs