Global.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Tencent is pleased to support the open source community by making Tars available.
  3. *
  4. * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
  5. *
  6. * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  7. * in compliance with the License. You may obtain a copy of the License at
  8. *
  9. * https://opensource.org/licenses/BSD-3-Clause
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. */
  16. #include "servant/Global.h"
  17. #include "servant/BaseF.h"
  18. #include "servant/RemoteLogger.h"
  19. namespace tars
  20. {
  21. //////////////////////////////////////////////////////////////////////////
  22. void TarsException::throwException(int ret, const string& desc)
  23. {
  24. switch (ret)
  25. {
  26. case tars::TARSSERVERSUCCESS:
  27. break;
  28. case TARSSERVERDECODEERR:
  29. throw TarsServerDecodeException("server decode exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  30. break;
  31. case TARSSERVERENCODEERR:
  32. throw TarsServerEncodeException("server encode exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  33. break;
  34. case TARSSERVERNOFUNCERR:
  35. throw TarsServerNoFuncException("server function mismatch exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  36. break;
  37. case TARSSERVERNOSERVANTERR:
  38. throw TarsServerNoServantException("server servant mismatch exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  39. break;
  40. case TARSSERVERQUEUETIMEOUT:
  41. throw TarsServerQueueTimeoutException("server queue timeout exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  42. break;
  43. case TARSPROXYCONNECTERR:
  44. throw TarsServerConnectionException("server connection lost: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  45. break;
  46. case TARSINVOKETIMEOUT:
  47. throw TarsServerInvokeTimeoutException(desc);
  48. default:
  49. throw TarsServerUnknownException("server unknown exception: ret:" + TC_Common::tostr(ret) + " msg:"+ desc);
  50. }
  51. }
  52. ////////////////////////////////////////////////////////////////////////////
  53. }