PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/MovableLabel/frameworks/The-M-Project/modules/core/foundation/error.js

https://github.com/sanyaade-gamedev/The-M-Project-Sample-Apps
JavaScript | 266 lines | 31 code | 32 blank | 203 comment | 0 complexity | 942fe7aba84776cc4d6358f1f162ebf5 MD5 | raw file
Possible License(s): GPL-2.0
  1. // ==========================================================================
  2. // Project: The M-Project - Mobile HTML5 Application Framework
  3. // Copyright: (c) 2010 M-Way Solutions GmbH. All rights reserved.
  4. // (c) 2011 panacoda GmbH. All rights reserved.
  5. // Creator: Sebastian
  6. // Date: 11.02.2011
  7. // License: Dual licensed under the MIT or GPL Version 2 licenses.
  8. // http://github.com/mwaylabs/The-M-Project/blob/master/MIT-LICENSE
  9. // http://github.com/mwaylabs/The-M-Project/blob/master/GPL-LICENSE
  10. // ==========================================================================
  11. m_require('core/utility/logger.js');
  12. /**
  13. * @class
  14. *
  15. * The root object for Error objects
  16. *
  17. * M.Error encapsulates errors in The-M-Project.
  18. * Should be passed to error callbacks.
  19. *
  20. * 0-99: general errors
  21. *
  22. * 100-199: Model and Validation errors
  23. *
  24. * 200-299: WebSQL errors
  25. *
  26. * 300-400: CouchDB errors
  27. *
  28. *
  29. * Constant Code Situation
  30. * -------- ---- ---------
  31. * M.ERR_UNDEFINED 0 The reason for the error could not be clarified.
  32. * M.ERR_CONNECTION 1 A connection to an external service could not be established
  33. *
  34. * M.ERR_VALIDATION_PRESENCE 100 A model record failed validation due to a property is not set but required to be.
  35. * M.ERR_VALIDATION_URL 101 A model record failed validation due to a property does not represent a valid URL but is required to do so.
  36. * M.ERR_VALIDATION_PHONE 102 A model record failed validation due to a property does not represent a phone number but is required to do so.
  37. * M.ERR_VALIDATION_NUMBER 103 A model record failed validation due to a property is not of type number or represents a number but is required to do so.
  38. * M.ERR_VALIDATION_NOTMINUS 104 A model record failed validation due to a property contains a minus value but it is required to do not.
  39. * M.ERR_VALIDATION_EMAIL 105 A model record failed validation due to a property does not represent a valid eMail but is required to do so.
  40. * M.ERR_VALIDATION_DATE 106 A model record failed validation due to a property does not represent a valid date but is required to do so.
  41. *
  42. * M.ERR_MODEL_PROVIDER_NOT_SET 120 A data provider has not been set.
  43. *
  44. * M.ERR_WEBSQL_UNKNOWN 200 The transaction failed for reasons unrelated to the database itself and not covered by any other error code.
  45. * M.ERR_WEBSQL_DATABASE 201 The statement failed for database reasons not covered by any other error code.
  46. * M.ERR_WEBSQL_VERSION 202 The operation failed because the actual database version was not what it should be. For example, a statement found that the actual database version no longer matched the expected version of the Database or DatabaseSync object, or the Database.changeVersion() or DatabaseSync.changeVersion() methods were passed a version that doesn't match the actual database version.
  47. * M.ERR_WEBSQL_TOO_LARGE 203 The statement failed because the data returned from the database was too large. The SQL "LIMIT" modifier might be useful to reduce the size of the result set.
  48. * M.ERR_WEBSQL_QUOTA 204 The statement failed because there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database.
  49. * M.ERR_WEBSQL_SYNTAX 205 The statement failed because of a syntax error, or the number of arguments did not match the number of ? placeholders in the statement, or the statement tried to use a statement that is not allowed, such as BEGIN, COMMIT, or ROLLBACK, or the statement tried to use a verb that could modify the database but the transaction was read-only.
  50. * M.ERR_WEBSQL_CONSTRAINT 206 An INSERT, UPDATE, or REPLACE statement failed due to a constraint failure. For example, because a row was being inserted and the value given for the primary key column duplicated the value of an existing row.
  51. * M.ERR_WEBSQL_TIMEOUT 207 A lock for the transaction could not be obtained in a reasonable time.
  52. * M.ERR_WEBSQL_PROVIDER_NO_DBHANDLER 208 No DBHandler, initialization did not take place or failed.
  53. * M.ERR_WEBSQL_BULK_NO_RECORDS 210 No Records given for bulk transaction
  54. *
  55. * M.ERR_COUCHDB_CONFLICT 300 A conflict occured while saving a document in CouchDB, propably caused by duplicate IDs
  56. * M.ERR_COUCHDB_DBNOTFOUND 301 The provided database could not be found.
  57. * M.ERR_COUCHDB_DBEXISTS 302 The db already exists and therefor cannot be created again.
  58. * M.ERR_COUCHDB_DOCNOTFOUND 303 No document was found for the provided ID in the database.
  59. *
  60. *
  61. *
  62. *
  63. * @extends M.Object
  64. */
  65. /**
  66. * A constant value for an undefined error.
  67. *
  68. * @type Number
  69. */
  70. M.ERR_UNDEFINED = 0;
  71. /**
  72. * A constant value for an error occuring when a connection to an external service could not be established.
  73. *
  74. * @type Number
  75. */
  76. M.ERR_CONNECTION = 1;
  77. /**
  78. * A model record failed validation due to a property is not set but required to be.
  79. *
  80. * @type Number
  81. */
  82. M.ERR_VALIDATION_PRESENCE = 100;
  83. /**
  84. * A model record failed validation due to a property does not represent a valid URL but is required to do so.
  85. *
  86. * @type Number
  87. */
  88. M.ERR_VALIDATION_URL = 101;
  89. /**
  90. * A model record failed validation due to a property does not represent a phone number but is required to do so.
  91. *
  92. * @type Number
  93. */
  94. M.ERR_VALIDATION_PHONE = 102;
  95. /**
  96. * A model record failed validation due to a property is not of type number or represents a number but is required to do so.
  97. *
  98. * @type Number
  99. */
  100. M.ERR_VALIDATION_NUMBER = 103;
  101. /**
  102. * A model record failed validation due to a property contains a minus value but it is required to do not.
  103. *
  104. * @type Number
  105. */
  106. M.ERR_VALIDATION_NOTMINUS = 104;
  107. /**
  108. * A model record failed validation due to a property does not represent a valid eMail but is required to do so.
  109. *
  110. * @type Number
  111. */
  112. M.ERR_VALIDATION_EMAIL = 105;
  113. /**
  114. * A model record failed validation due to a property does not represent a valid eMail but is required to do so.
  115. *
  116. * @type Number
  117. */
  118. M.ERR_VALIDATION_DATE = 106;
  119. /**
  120. * A Data Provider was not set for a model.
  121. *
  122. * @type Number
  123. */
  124. M.ERR_MODEL_PROVIDER_NOT_SET = 120;
  125. /* WebSQL Error Codes (see e.g. http://www.w3.org/TR/webdatabase/) */
  126. /**
  127. * A constant value for an error occuring with WebSQL.
  128. * "The transaction failed for reasons unrelated to the database itself and not covered by any other error code."
  129. * Error code in WebSQL specification: 0
  130. *
  131. * @type Number
  132. */
  133. M.ERR_WEBSQL_UNKNOWN = 200;
  134. /**
  135. * A constant value for an error occuring with WebSQL.
  136. * "The statement failed for database reasons not covered by any other error code."
  137. * Error code in WebSQL specification: 1
  138. *
  139. * @type Number
  140. */
  141. M.ERR_WEBSQL_DATABASE = 201;
  142. /**
  143. * A constant value for an error occuring with WebSQL.
  144. * "The transaction failed for reasons unrelated to the database itself and not covered by any other error code."
  145. * Error code in WebSQL specification: 2
  146. *
  147. * @type Number
  148. */
  149. M.ERR_WEBSQL_VERSION = 202;
  150. /**
  151. * A constant value for an error occuring with WebSQL.
  152. * "The statement failed because the data returned from the database was too large. The SQL "LIMIT" modifier might be useful to reduce the size of the result set."
  153. * Error code in WebSQL specification: 3
  154. *
  155. * @type Number
  156. */
  157. M.ERR_WEBSQL_TOO_LARGE = 203;
  158. /**
  159. * A constant value for an error occuring with WebSQL.
  160. * "The statement failed because there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database."
  161. * Error code in WebSQL specification: 4
  162. *
  163. * @type Number
  164. */
  165. M.ERR_WEBSQL_QUOTA = 204;
  166. /**
  167. * A constant value for an error occuring with WebSQL.
  168. * "The statement failed because of a syntax error, or the number of arguments did not match the number of ? placeholders in the statement, or the statement tried to use a statement that is not allowed, such as BEGIN, COMMIT, or ROLLBACK, or the statement tried to use a verb that could modify the database but the transaction was read-only."
  169. * Error code in WebSQL specification: 5
  170. *
  171. * @type Number
  172. */
  173. M.ERR_WEBSQL_SYNTAX = 205;
  174. /**
  175. * A constant value for an error occuring with WebSQL.
  176. * "An INSERT, UPDATE, or REPLACE statement failed due to a constraint failure. For example, because a row was being inserted and the value given for the primary key column duplicated the value of an existing row."
  177. * Error code in WebSQL specification: 6
  178. *
  179. * @type Number
  180. */
  181. M.ERR_WEBSQL_CONSTRAINT = 206;
  182. /**
  183. * A constant value for an error occuring with WebSQL.
  184. * "A lock for the transaction could not be obtained in a reasonable time."
  185. * Error code in WebSQL specification: 7
  186. *
  187. * @type Number
  188. */
  189. M.ERR_WEBSQL_TIMEOUT = 207;
  190. /* following errors are WebSQL Data Provider errors. */
  191. /**
  192. * A constant value for an error occuring when dbHandler does not exist in
  193. * data provider. Reason: Initialization did not take place or failed.
  194. *
  195. * @type Number
  196. */
  197. M.ERR_WEBSQL_PROVIDER_NO_DBHANDLER = 208;
  198. /**
  199. * A constant value for an error occuring with bulkSave operation in dataprovider.
  200. * No Record array was passed to the method via the param obj.
  201. *
  202. * @type Number
  203. */
  204. M.ERR_WEBSQL_BULK_NO_RECORDS = 210;
  205. /**
  206. * A constant value for an error occuring when a conflict appears when saving a document in CouchDB. This is propably caused by duplicate IDs
  207. *
  208. * @type Number
  209. */
  210. M.ERR_COUCHDB_CONFLICT = 300;
  211. /**
  212. * A constant value for an error occuring if the provided database could not be found
  213. *
  214. * @type Number
  215. */
  216. M.ERR_COUCHDB_DBNOTFOUND = 301;
  217. /**
  218. * A constant value for an error occuring if a database that shall be created already exists
  219. *
  220. * @type Number
  221. */
  222. M.ERR_COUCHDB_DBEXISTS = 302;
  223. /**
  224. * A constant value for an error occuring if a document could not be found
  225. *
  226. * @type Number
  227. */
  228. M.ERR_COUCHDB_DOCNOTFOUND = 303;
  229. M.Error = M.Object.extend(
  230. /** @scope M.Error.prototype */ {
  231. code: '',
  232. msg: '',
  233. errObj: null
  234. });