| <?php |
| |
| /** |
| * Set global THRIFT ROOT automatically via inclusion here |
| */ |
| if (!isset($GLOBALS['THRIFT_ROOT'])) { |
| $GLOBALS['THRIFT_ROOT'] = dirname(__FILE__); |
| } |
| include_once $GLOBALS['THRIFT_ROOT'].'/protocol/TProtocol.php'; |
| |
| class TException extends Exception { |
| function __construct($message=null, $code=0) { |
| parent::__construct($message, $code); |
| } |
| } |
| |
| class TApplicationException extends TException { |
| |
| const UNKNOWN = 0; |
| const UNKNOWN_METHOD = 1; |
| const INVALID_MESSAGE_TYPE = 2; |
| const WRONG_METHOD_NAME = 3; |
| const BAD_SEQUENCE_ID = 4; |
| const MISSING_RESULT = 5; |
| |
| function __construct($message=null, $code=0) { |
| parent::__construct($message, $code); |
| } |
| |
| public function read($input) { |
| $xfer = 0; |
| $fname = null; |
| $ftype = 0; |
| $fid = 0; |
| $xfer += $input->readStructBegin($fname); |
| while (true) |
| { |
| $xfer += $input->readFieldBegin($fname, $ftype, $fid); |
| if ($ftype == TType::STOP) { |
| break; |
| } |
| switch ($fid) |
| { |
| case 1: |
| if ($ftype == TType::STRING) { |
| $xfer += $input->readString($this->message); |
| } else { |
| $xfer += $input->skip($ftype); |
| } |
| break; |
| case 2: |
| if ($ftype == TType::I32) { |
| $xfer += $input->readI32($this->code); |
| } else { |
| $xfer += $input->skip($ftype); |
| } |
| break; |
| default: |
| $xfer += $input->skip($ftype); |
| break; |
| } |
| $xfer += $input->readFieldEnd(); |
| } |
| $xfer += $input->readStructEnd(); |
| return $xfer; |
| } |
| |
| public function write($output) { |
| $xfer = 0; |
| $xfer += $output->writeStructBegin('TApplicationException'); |
| if ($this->getMessage()) { |
| $xfer += $output->writeFieldBegin('message', TType::STRING, 1); |
| $xfer += $output->writeString($this->getMessage()); |
| $xfer += $output->writeFieldEnd(); |
| } |
| if ($this->type !== null) { |
| $xfer += $output->writeFieldBegin('type', TType::I32, 2); |
| $xfer += $output->writeI32($this->getCode()); |
| $xfer += $output->writeFieldEnd(); |
| } |
| $xfer += $output->writeFieldStop(); |
| $xfer += $output->writeStructEnd(); |
| return $xfer; |
| } |
| } |
| |
| |
| ?> |