TApplicationException.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. * @package thrift
  21. */
  22. namespace Thrift\Exception;
  23. use Thrift\Type\TType;
  24. class TApplicationException extends TException
  25. {
  26. static $_TSPEC =
  27. array(1 => array('var' => 'message',
  28. 'type' => TType::STRING),
  29. 2 => array('var' => 'code',
  30. 'type' => TType::I32));
  31. const UNKNOWN = 0;
  32. const UNKNOWN_METHOD = 1;
  33. const INVALID_MESSAGE_TYPE = 2;
  34. const WRONG_METHOD_NAME = 3;
  35. const BAD_SEQUENCE_ID = 4;
  36. const MISSING_RESULT = 5;
  37. const INTERNAL_ERROR = 6;
  38. const PROTOCOL_ERROR = 7;
  39. const INVALID_TRANSFORM = 8;
  40. const INVALID_PROTOCOL = 9;
  41. const UNSUPPORTED_CLIENT_TYPE = 10;
  42. public function __construct($message=null, $code=0)
  43. {
  44. parent::__construct($message, $code);
  45. }
  46. public function read($output)
  47. {
  48. return $this->_read('TApplicationException', self::$_TSPEC, $output);
  49. }
  50. public function write($output)
  51. {
  52. $xfer = 0;
  53. $xfer += $output->writeStructBegin('TApplicationException');
  54. if ($message = $this->getMessage()) {
  55. $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
  56. $xfer += $output->writeString($message);
  57. $xfer += $output->writeFieldEnd();
  58. }
  59. if ($code = $this->getCode()) {
  60. $xfer += $output->writeFieldBegin('type', TType::I32, 2);
  61. $xfer += $output->writeI32($code);
  62. $xfer += $output->writeFieldEnd();
  63. }
  64. $xfer += $output->writeFieldStop();
  65. $xfer += $output->writeStructEnd();
  66. return $xfer;
  67. }
  68. }