1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | 1× 1× 1× 1× 1× 18× 15× 14× 1× 4× 4× 6× 5× 1× 17× 9× 8× 6× 3× 6× 1× 14× 2× 1× 19× 43× 17× | 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _utils = require('../utils'); var _utils2 = _interopRequireDefault(_utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { errors: function errors(api) { return { '_toExpand': false, // --------------------------------------------------------------------- // [SERIALIZERS] // --------------------------------------------------------------------- serializers: { servers: { web: function web(error) { if (_utils2.default.isError(error)) { return String(error.message); } else { return error; } }, websocket: function websocket(error) { Eif (_utils2.default.isError(error)) { return String(error.message); } else { return error; } }, tcp: function tcp(error) { if (_utils2.default.isError(error)) { return String(error.message); } else { return error; } }, helper: function helper(error) { if (_utils2.default.isError(error)) { return 'Error: ' + String(error.message); } else { return error; } } } }, // --------------------------------------------------------------------- // [GENERAL ERRORS] // --------------------------------------------------------------------- // --------------------------------------------------------------------- // The message to accompany general 500 errors (internal server errors) // --------------------------------------------------------------------- serverErrorMessage: function serverErrorMessage() { return 'The server experienced an internal error'; }, // --------------------------------------------------------------------- // When a client make a call to a private action // --------------------------------------------------------------------- privateActionCalled: function privateActionCalled(actionName) { return 'the action \'' + actionName + '\' is private'; }, // --------------------------------------------------------------------- // When a params for an action is invalid // --------------------------------------------------------------------- invalidParams: function invalidParams(params) { return params.join(', '); }, // --------------------------------------------------------------------- // When a required param for an action is not provided // --------------------------------------------------------------------- missingParams: function missingParams(params) { return params[0] + ' is a required parameter for this action'; }, // --------------------------------------------------------------------- // When a param was an invalid type // --------------------------------------------------------------------- paramInvalidType: function paramInvalidType(paramName, expected) { return 'param \'' + paramName + '\' has an invalid type, expected ' + expected; }, // --------------------------------------------------------------------- // user required an unknown action // --------------------------------------------------------------------- unknownAction: function unknownAction(action) { return 'unknown action or invalid apiVersion'; }, // --------------------------------------------------------------------- // action can be called by this client/server type // --------------------------------------------------------------------- unsupportedServerType: function unsupportedServerType(type) { return 'this action does not support the ' + type + ' connection type'; }, // --------------------------------------------------------------------- // Action failed because server is mid-shutdown // --------------------------------------------------------------------- serverShuttingDown: function serverShuttingDown() { return 'the server is shutting down'; }, // --------------------------------------------------------------------- // action failed because this client already has too many pending // actions // // the limit is defined in api.config.general.simultaneousActions // --------------------------------------------------------------------- tooManyPendingActions: function tooManyPendingActions() { return 'you have too many pending requests'; }, // --------------------------------------------------------------------- // data length is too big // // the limit can be configured using: // api.config.servers.tcp.maxDataLength // --------------------------------------------------------------------- dataLengthTooLarge: function dataLengthTooLarge(maxLength, receivedLength) { return api.i18n.localize('data length is too big (' + maxLength + ' received/' + receivedLength + ' max)'); }, // --------------------------------------------------------------------- // a poorly designed action cloud try to call next() more than once // --------------------------------------------------------------------- doubleCallbackError: function doubleCallbackError() { return 'Double callback prevented within action'; }, // --------------------------------------------------------------------- // function to be executed when a file to exists // --------------------------------------------------------------------- fileNotFound: function fileNotFound() { return 'The requested file not exists'; }, // --------------------------------------------------------------------- // function to be executed when occurs a error during file reading // --------------------------------------------------------------------- fileReadError: function fileReadError(connection, error) { return connection.localize('error reading file: ' + String(error)); }, // --------------------------------------------------------------------- // User didn't request a file // --------------------------------------------------------------------- fileNotProvided: function fileNotProvided() { return 'File is a required param to send a file'; }, // --------------------------------------------------------------------- // Connections // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Function to be executed when a verb is'nt found // --------------------------------------------------------------------- verbNotFound: function verbNotFound(connection, verb) { return connection.localize('the verb non\'t exists (' + verb + ')'); }, // --------------------------------------------------------------------- // Function to be executed when a verb isn't not allowed // --------------------------------------------------------------------- verbNotAllowed: function verbNotAllowed(connection, verb) { return connection.localize('verb not found or not allowed (' + verb + ')'); }, // --------------------------------------------------------------------- // Error handler when the room and the message are not present on the // request. // --------------------------------------------------------------------- connectionRoomAndMessage: function connectionRoomAndMessage(connection) { return connection.localize('both room and message are required'); }, // --------------------------------------------------------------------- // Error handle for a request made to a room who the user as not part of // --------------------------------------------------------------------- connectionNotInRoom: function connectionNotInRoom(connection, room) { return connection.localize('connection not in this room (' + room + ')'); }, // --------------------------------------------------------------------- // Error handler for a join request to a room which the user is already // part // --------------------------------------------------------------------- connectionAlreadyInRoom: function connectionAlreadyInRoom(connection, room) { return connection.localize('connection already in this room (' + room + ')'); }, // --------------------------------------------------------------------- // Error handle request for a deleted room. // --------------------------------------------------------------------- connectionRoomHasBeenDeleted: function connectionRoomHasBeenDeleted(room) { return 'this room has been deleted'; }, // --------------------------------------------------------------------- // Error handler for a join request to a not existing room // --------------------------------------------------------------------- connectionRoomNotExist: function connectionRoomNotExist(room) { return 'room does not exist'; }, // --------------------------------------------------------------------- // Error handler for a room creation request with a same name a already // existing room // --------------------------------------------------------------------- connectionRoomExists: function connectionRoomExists(room) { return 'room exists'; }, // --------------------------------------------------------------------- // Error handler for a request who need a room name and that parameter // are not present. // --------------------------------------------------------------------- connectionRoomRequired: function connectionRoomRequired(room) { return 'a room is required'; } }; } }; //# sourceMappingURL=errors.js.map |