View Full Version : Problem using Java Exceptions in PHP

12-28-2009, 05:04 AM
I am using PHP for presentation and Java for Business Logic.

My code is working fine. But when i throw exceptions from Business Logic its giving problem.

Here is the code segment:

Java Code

package com.vm.php;
public class Database
public String addProfile(Profile profile) throws NullException, InvalidDataException
if(null == profile)
throw new NullException();

if(null == profile.getFirstName())
throw new InvalidDataException();

return "success";

PHP Code

import com.vm.php.Database;
import com.vm.php.exceptions.NullException;
import com.vm.php.exceptions.InvalidDataException;

echo "<pre>";
echo "working";

$database = new Java("Database");
try {
} catch(NullException $ex) {
echo "<br />";
echo 'NullException: ', $ex->getMessage(), "\n";
} catch(InvalidDataException $ex) {
echo "<br />";
echo 'InvalidDataException: ', $ex->getMessage(), "\n";
echo "</pre>";

It is possible to catch exceptions using Quercus?

Thanks in advance..... :)

Raghu Krishna Kuchi

12-29-2009, 03:03 AM
Hmm. You certainly catch all exceptions with catch (Exception $e), but currently the Exception type matching might be based on PHP exceptions, not Java Exceptions.