Source: Status.js

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var Guacamole = Guacamole || {};
  20. /**
  21. * A Guacamole status. Each Guacamole status consists of a status code, defined
  22. * by the protocol, and an optional human-readable message, usually only
  23. * included for debugging convenience.
  24. *
  25. * @constructor
  26. * @param {Number} code
  27. * The Guacamole status code, as defined by Guacamole.Status.Code.
  28. *
  29. * @param {String} [message]
  30. * An optional human-readable message.
  31. */
  32. Guacamole.Status = function(code, message) {
  33. /**
  34. * Reference to this Guacamole.Status.
  35. * @private
  36. */
  37. var guac_status = this;
  38. /**
  39. * The Guacamole status code.
  40. * @see Guacamole.Status.Code
  41. * @type {Number}
  42. */
  43. this.code = code;
  44. /**
  45. * An arbitrary human-readable message associated with this status, if any.
  46. * The human-readable message is not required, and is generally provided
  47. * for debugging purposes only. For user feedback, it is better to translate
  48. * the Guacamole status code into a message.
  49. *
  50. * @type {String}
  51. */
  52. this.message = message;
  53. /**
  54. * Returns whether this status represents an error.
  55. * @returns {Boolean} true if this status represents an error, false
  56. * otherwise.
  57. */
  58. this.isError = function() {
  59. return guac_status.code < 0 || guac_status.code > 0x00FF;
  60. };
  61. };
  62. /**
  63. * Enumeration of all Guacamole status codes.
  64. */
  65. Guacamole.Status.Code = {
  66. /**
  67. * The operation succeeded.
  68. *
  69. * @type {Number}
  70. */
  71. "SUCCESS": 0x0000,
  72. /**
  73. * The requested operation is unsupported.
  74. *
  75. * @type {Number}
  76. */
  77. "UNSUPPORTED": 0x0100,
  78. /**
  79. * The operation could not be performed due to an internal failure.
  80. *
  81. * @type {Number}
  82. */
  83. "SERVER_ERROR": 0x0200,
  84. /**
  85. * The operation could not be performed as the server is busy.
  86. *
  87. * @type {Number}
  88. */
  89. "SERVER_BUSY": 0x0201,
  90. /**
  91. * The operation could not be performed because the upstream server is not
  92. * responding.
  93. *
  94. * @type {Number}
  95. */
  96. "UPSTREAM_TIMEOUT": 0x0202,
  97. /**
  98. * The operation was unsuccessful due to an error or otherwise unexpected
  99. * condition of the upstream server.
  100. *
  101. * @type {Number}
  102. */
  103. "UPSTREAM_ERROR": 0x0203,
  104. /**
  105. * The operation could not be performed as the requested resource does not
  106. * exist.
  107. *
  108. * @type {Number}
  109. */
  110. "RESOURCE_NOT_FOUND": 0x0204,
  111. /**
  112. * The operation could not be performed as the requested resource is
  113. * already in use.
  114. *
  115. * @type {Number}
  116. */
  117. "RESOURCE_CONFLICT": 0x0205,
  118. /**
  119. * The operation could not be performed as the requested resource is now
  120. * closed.
  121. *
  122. * @type {Number}
  123. */
  124. "RESOURCE_CLOSED": 0x0206,
  125. /**
  126. * The operation could not be performed because bad parameters were given.
  127. *
  128. * @type {Number}
  129. */
  130. "CLIENT_BAD_REQUEST": 0x0300,
  131. /**
  132. * Permission was denied to perform the operation, as the user is not yet
  133. * authorized (not yet logged in, for example).
  134. *
  135. * @type {Number}
  136. */
  137. "CLIENT_UNAUTHORIZED": 0x0301,
  138. /**
  139. * Permission was denied to perform the operation, and this permission will
  140. * not be granted even if the user is authorized.
  141. *
  142. * @type {Number}
  143. */
  144. "CLIENT_FORBIDDEN": 0x0303,
  145. /**
  146. * The client took too long to respond.
  147. *
  148. * @type {Number}
  149. */
  150. "CLIENT_TIMEOUT": 0x0308,
  151. /**
  152. * The client sent too much data.
  153. *
  154. * @type {Number}
  155. */
  156. "CLIENT_OVERRUN": 0x030D,
  157. /**
  158. * The client sent data of an unsupported or unexpected type.
  159. *
  160. * @type {Number}
  161. */
  162. "CLIENT_BAD_TYPE": 0x030F,
  163. /**
  164. * The operation failed because the current client is already using too
  165. * many resources.
  166. *
  167. * @type {Number}
  168. */
  169. "CLIENT_TOO_MANY": 0x031D
  170. };