Error.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // "$Id: Error.h 106479 2013-03-18 05:55:07Z wang_haifeng $"
  3. //
  4. // Copyright (c)1992-2007, ZheJiang Dahua Technology Stock CO.LTD.
  5. // All Rights Reserved.
  6. //
  7. // Description:
  8. // Revisions: Year-Month-Day SVN-Author Modification
  9. //
  10. #ifndef __INFRA3_ERROR_H__
  11. #define __INFRA3_ERROR_H__
  12. #include "String.h"
  13. #include "Defs.h"
  14. namespace Dahua {
  15. /////////////////////////////////////////////////////////////////////////
  16. // Error Number Define For
  17. enum InfraError
  18. {
  19. // 与 linux 兼容的错误号
  20. errorPERM = 1, ///< Operation not permitted
  21. errorNOFILE = 2, ///< No such file or directory
  22. errorNOENT = 2,
  23. errorSRCH = 3, ///< No such process
  24. errorINTR = 4, ///< Interrupted function call
  25. errorIO = 5, ///< Input/output error
  26. errorNXIO = 6, ///< No such device or address
  27. error2BIG = 7, ///< Arg list too long
  28. errorNOEXEC = 8, ///< Exec format error
  29. errorBADF = 9, ///< Bad file descriptor
  30. errorCHILD = 10, ///< No child processes
  31. errorAGAIN = 11, ///< Resource temporarily unavailable
  32. errorNOMEM = 12, ///< Not enough space
  33. errorACCES = 13, ///< Permission denied
  34. errorFAULT = 14, ///< Bad address
  35. errorBUSY = 16, ///< strerror reports "Resource device"
  36. errorEXIST = 17, ///< File exists
  37. errorXDEV = 18, ///< Improper link (cross-device link?)
  38. errorNODEV = 19, ///< No such device
  39. errorNOTDIR = 20, ///< Not a directory
  40. errorISDIR = 21, ///< Is a directory
  41. errorINVAL = 22, ///< Invalid argument
  42. errorNFILE = 23, ///< Too many open files in system
  43. errorMFILE = 24, ///< Too many open files
  44. errorNOTTY = 25, ///< Inappropriate I/O control operation
  45. errorFBIG = 27, ///< File too large
  46. errorNOSPC = 28, ///< No space left on device
  47. errorSPIPE = 29, ///< Invalid seek (seek on a pipe?)
  48. errorROFS = 30, ///< Read-only file system
  49. errorMLINK = 31, ///< Too many links
  50. errorPIPE = 32, ///< Broken pipe
  51. errorDOM = 33, ///< Domain error (math functions)
  52. errorRANGE = 34, ///< Result too large (possibly too small)
  53. errorDEADLOCK = 36, ///< Resource deadlock avoided (non-Cyg)
  54. errorDEADLK = 36,
  55. errorNAMETOOLONG= 38, ///< Filename too long (91 in Cyg?)
  56. errorNOLCK = 39, ///< No locks available (46 in Cyg?)
  57. errorNOSYS = 40, ///< Function not implemented (88 in Cyg?)
  58. errorNOTEMPTY = 41, ///< Directory not empty (90 in Cyg?)
  59. errorILSEQ = 42, ///< Illegal byte sequence
  60. // Infra 组件错误号
  61. infraErrorNoFound = 0x10000000, ///< 没有找到指定的对象
  62. infraErrorExist = 0x10000001, ///< 对象已经存在
  63. infraErrorFull = 0x10000002, ///< 容器达到个数上限
  64. infraErrorEmptyProc = 0x10000003, ///< 对象包含的函数指针为空,没有意义
  65. infraErrorNotInTimeSection = 0x10000004, ///< 不在时间段内
  66. infraErrorPalInterfaceEmpty = 0x10000005, ///< PAL 接口未实现
  67. infraErrorPalCallFailed = 0x10000006, ///< PAL 接口调用失败
  68. infraErrorThreadIsRunning = 0x10000007, ///< 线程正在运行
  69. infraErrorThreadNotExist = 0x10000008, ///< 线程不存在
  70. infraErrorThreadNotManaged = 0x10000009, ///< 线程未被管理
  71. infraErrorTlsOutOfIndexes = 0x1000000a, ///< TLS 索引不正确
  72. infraErrorTimerNotStarted = 0x1000000b, ///< 定时器未开启
  73. infraErrorTimerIsRunning = 0x1000000c, ///< 定时器正在运行
  74. infraErrorPacketNoFree = 0x1000000d, ///< Packet 内存空间不足
  75. infraErrorModifySysTimeFailed = 0x1000000e, ///< 直接修改系统时间失败
  76. infraErrorSyncRtcTimeFailed = 0x1000000f, ///< 修改时间时RTC时钟同步失败或者回调函数(一般用于同步rtc时钟)失败
  77. };
  78. namespace Infra {
  79. /// 调用系统函数出错时,设置调用线程最后一个错误。
  80. /// 各组件内部逻辑出错时,应该掉用此接口根据不同原因设置错误号。如果是调用
  81. /// 系统函数或者其他非组件库出错时,也应该将(errno)的值设置为当前错误。
  82. INFRA_API void setLastError(int eno);
  83. /// 获取调用线程最后一个错误,使用linux兼容错误码。
  84. INFRA_API int getLastError();
  85. /// 设置错误码对应的错误字符串
  86. INFRA_API void setErrMsg(int eno, const char* message);
  87. /// 根据错误码获取错误字符串。
  88. INFRA_API const char* getErrMsg(int eno);
  89. /// 设置错误码对应的错误字符串
  90. INFRA_API void setErrorMessage(int eno, CString2 const& message);
  91. /// 根据错误码获取错误字符串。
  92. INFRA_API CString2 getErrorMessage(int eno);
  93. } // namespace Infra
  94. } // namespace Dahua
  95. #endif //__INFRA_ERROR_H__