NRKernalException.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System;
  2. namespace NRKernal
  3. {
  4. public enum Level
  5. {
  6. High,
  7. Normal,
  8. }
  9. /// <summary> A nr kernal error. </summary>
  10. public class NRKernalError : ApplicationException
  11. {
  12. public Level level;
  13. /// <summary> The error message. </summary>
  14. protected string msg;
  15. /// <summary> The inner exception. </summary>
  16. protected Exception innerException;
  17. /// <summary> Constructor. </summary>
  18. /// <param name="msg"> The message.</param>
  19. /// <param name="innerException"> (Optional) The inner exception.</param>
  20. public NRKernalError(string msg, Level level = Level.Normal, Exception innerException = null) : base(msg)
  21. {
  22. this.innerException = innerException;
  23. this.msg = msg;
  24. this.level = level;
  25. }
  26. /// <summary> Gets the error. </summary>
  27. /// <returns> The error. </returns>
  28. virtual public string GetErrorMsg()
  29. {
  30. return msg;
  31. }
  32. }
  33. #region native error
  34. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35. /// /// internal errors
  36. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37. /// <summary> A nr kernal error. </summary>
  38. public class NRNativeError : NRKernalError
  39. {
  40. public NativeResult result;
  41. /// <summary> Constructor. </summary>
  42. /// <param name="msg"> The message.</param>
  43. /// <param name="innerException"> (Optional) The inner exception.</param>
  44. public NRNativeError(NativeResult result, string msg, Level level = Level.Normal, Exception innerException = null) : base(msg, level, innerException)
  45. {
  46. this.result = result;
  47. }
  48. /// <summary> Gets the error. </summary>
  49. /// <returns> The error. </returns>
  50. override public string GetErrorMsg()
  51. {
  52. return string.Format("Error Code-{0}: {1}", (int)result, msg);
  53. }
  54. }
  55. /// <summary> A nr invalid argument error. </summary>
  56. public class NRInvalidArgumentError : NRNativeError
  57. {
  58. /// <summary> Constructor. </summary>
  59. /// <param name="msg"> The message.</param>
  60. /// <param name="innerException"> (Optional) The inner exception.</param>
  61. public NRInvalidArgumentError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.Normal, innerException)
  62. {
  63. }
  64. }
  65. /// <summary> A nr not enough memory error. </summary>
  66. public class NRNotEnoughMemoryError : NRNativeError
  67. {
  68. /// <summary> Constructor. </summary>
  69. /// <param name="msg"> The message.</param>
  70. /// <param name="innerException"> (Optional) The inner exception.</param>
  71. public NRNotEnoughMemoryError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  72. {
  73. }
  74. }
  75. /// <summary> A nr sdcard permission deny error. </summary>
  76. public class NRSdcardPermissionDenyError : NRNativeError
  77. {
  78. /// <summary> Constructor. </summary>
  79. /// <param name="msg"> The message.</param>
  80. /// <param name="innerException"> (Optional) The inner exception.</param>
  81. public NRSdcardPermissionDenyError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  82. {
  83. }
  84. }
  85. /// <summary> A nr un supported error. </summary>
  86. public class NRUnSupportedError : NRNativeError
  87. {
  88. /// <summary> Constructor. </summary>
  89. /// <param name="msg"> The message.</param>
  90. /// <param name="innerException"> (Optional) The inner exception.</param>
  91. public NRUnSupportedError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  92. {
  93. }
  94. }
  95. /// <summary> A nr glasses connect error. </summary>
  96. public class NRGlassesConnectError : NRNativeError
  97. {
  98. /// <summary> Constructor. </summary>
  99. /// <param name="msg"> The message.</param>
  100. /// <param name="innerException"> (Optional) The inner exception.</param>
  101. public NRGlassesConnectError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  102. {
  103. }
  104. }
  105. /// <summary> A nr sdk version mismatch error. </summary>
  106. public class NRSdkVersionMismatchError : NRNativeError
  107. {
  108. /// <summary> Constructor. </summary>
  109. /// <param name="msg"> The message.</param>
  110. /// <param name="innerException"> (Optional) The inner exception.</param>
  111. public NRSdkVersionMismatchError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  112. {
  113. }
  114. }
  115. /// <summary> A nr rgb camera device not find error. </summary>
  116. public class NRRGBCameraDeviceNotFindError : NRNativeError
  117. {
  118. /// <summary> Constructor. </summary>
  119. /// <param name="msg"> The message.</param>
  120. /// <param name="innerException"> (Optional) The inner exception.</param>
  121. public NRRGBCameraDeviceNotFindError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.Normal, innerException)
  122. {
  123. }
  124. }
  125. /// <summary> Display device not find error. </summary>
  126. public class NRDPDeviceNotFindError : NRNativeError
  127. {
  128. /// <summary> Constructor. </summary>
  129. /// <param name="msg"> The message.</param>
  130. /// <param name="innerException"> (Optional) The inner exception.</param>
  131. public NRDPDeviceNotFindError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  132. {
  133. }
  134. }
  135. /// <summary> MRSpace display device not find error. </summary>
  136. public class NRGetDisplayFailureError : NRNativeError
  137. {
  138. /// <summary> Constructor. </summary>
  139. /// <param name="msg"> The message.</param>
  140. /// <param name="innerException"> (Optional) The inner exception.</param>
  141. public NRGetDisplayFailureError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  142. {
  143. }
  144. }
  145. /// <summary> Display Mode mismatch error, as MRSpace mode is needed. </summary>
  146. public class NRDisplayModeMismatchError : NRNativeError
  147. {
  148. /// <summary> Constructor. </summary>
  149. /// <param name="msg"> The message.</param>
  150. /// <param name="innerException"> (Optional) The inner exception.</param>
  151. public NRDisplayModeMismatchError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.High, innerException)
  152. {
  153. }
  154. }
  155. /// <summary> A device not support hand tracking calculation error. </summary>
  156. public class NRUnSupportedHandtrackingCalculationError : NRNativeError
  157. {
  158. /// <summary> Constructor. </summary>
  159. /// <param name="msg"> The message.</param>
  160. /// <param name="innerException"> (Optional) The inner exception.</param>
  161. public NRUnSupportedHandtrackingCalculationError(NativeResult result, string msg, Exception innerException = null) : base(result, msg, Level.Normal, innerException)
  162. {
  163. }
  164. }
  165. #endregion
  166. #region internal error
  167. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  168. /// /// internal errors
  169. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  170. /// <summary> A nr internal error. </summary>
  171. public class NRInternalError : NRKernalError
  172. {
  173. /// <summary> Constructor. </summary>
  174. /// <param name="msg"> The message.</param>
  175. /// <param name="innerException"> (Optional) The inner exception.</param>
  176. public NRInternalError(string msg, Level level = Level.Normal, Exception innerException = null) : base(msg, level, innerException)
  177. {
  178. }
  179. }
  180. public class NRMissingKeyComponentError : NRInternalError
  181. {
  182. /// <summary> Constructor. </summary>
  183. /// <param name="msg"> The message.</param>
  184. /// <param name="innerException"> (Optional) The inner exception.</param>
  185. public NRMissingKeyComponentError(string msg, Exception innerException = null) : base(msg, Level.High, innerException)
  186. {
  187. }
  188. }
  189. public class NRPermissionDenyError : NRInternalError
  190. {
  191. /// <summary> Constructor. </summary>
  192. /// <param name="msg"> The message.</param>
  193. /// <param name="innerException"> (Optional) The inner exception.</param>
  194. public NRPermissionDenyError(string msg, Exception innerException = null) : base(msg, Level.Normal, innerException)
  195. {
  196. }
  197. }
  198. public class NRUnSupportDeviceError : NRInternalError
  199. {
  200. /// <summary> Constructor. </summary>
  201. /// <param name="msg"> The message.</param>
  202. /// <param name="innerException"> (Optional) The inner exception.</param>
  203. public NRUnSupportDeviceError(string msg, Exception innerException = null) : base(msg, Level.High, innerException)
  204. {
  205. }
  206. }
  207. /// <summary> A nr glasses not available error. </summary>
  208. public class NRGlassesNotAvailbleError : NRInternalError
  209. {
  210. /// <summary> Constructor. </summary>
  211. /// <param name="msg"> The message.</param>
  212. /// <param name="innerException"> (Optional) The inner exception.</param>
  213. public NRGlassesNotAvailbleError(string msg, Exception innerException = null) : base(msg, Level.High, innerException)
  214. {
  215. }
  216. }
  217. #endregion
  218. }