2018-02-27 12:16:17 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
// error messages can be strings of objects
|
|
|
|
exports['default'] = {
|
2018-12-17 16:34:32 +00:00
|
|
|
errors: api => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return {
|
2018-12-17 16:34:32 +00:00
|
|
|
_toExpand: false,
|
2018-02-27 12:16:17 +00:00
|
|
|
|
|
|
|
// ///////////////
|
|
|
|
// SERIALIZERS //
|
|
|
|
// ///////////////
|
|
|
|
|
|
|
|
serializers: {
|
|
|
|
servers: {
|
2018-12-17 16:34:32 +00:00
|
|
|
web: error => {
|
2018-02-27 12:16:17 +00:00
|
|
|
if (error.message) {
|
|
|
|
return String(error.message)
|
|
|
|
} else {
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
},
|
2018-12-17 16:34:32 +00:00
|
|
|
websocket: error => {
|
2018-02-27 12:16:17 +00:00
|
|
|
if (error.message) {
|
|
|
|
return String(error.message)
|
|
|
|
} else {
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
},
|
2018-12-17 16:34:32 +00:00
|
|
|
socket: error => {
|
2018-02-27 12:16:17 +00:00
|
|
|
if (error.message) {
|
|
|
|
return String(error.message)
|
|
|
|
} else {
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
},
|
2018-12-17 16:34:32 +00:00
|
|
|
specHelper: error => {
|
2018-02-27 12:16:17 +00:00
|
|
|
if (error.message) {
|
|
|
|
return 'Error: ' + String(error.message)
|
|
|
|
} else {
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// ///////////
|
|
|
|
// ACTIONS //
|
|
|
|
// ///////////
|
|
|
|
|
|
|
|
// When a params for an action is invalid
|
|
|
|
invalidParams: (data, validationErrors) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
if (validationErrors.length >= 0) {
|
|
|
|
return validationErrors[0]
|
|
|
|
}
|
2018-02-27 12:16:17 +00:00
|
|
|
return data.connection.localize('actionhero.errors.invalidParams')
|
|
|
|
},
|
|
|
|
|
|
|
|
// When a required param for an action is not provided
|
|
|
|
missingParams: (data, missingParams) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return data.connection.localize([
|
|
|
|
'actionhero.errors.missingParams',
|
|
|
|
{ param: missingParams[0] }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// user requested an unknown action
|
2018-12-17 16:34:32 +00:00
|
|
|
unknownAction: data => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return data.connection.localize('actionhero.errors.unknownAction')
|
|
|
|
},
|
|
|
|
|
|
|
|
// action not useable by this client/server type
|
2018-12-17 16:34:32 +00:00
|
|
|
unsupportedServerType: data => {
|
|
|
|
return data.connection.localize([
|
|
|
|
'actionhero.errors.unsupportedServerType',
|
|
|
|
{ type: data.connection.type }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// action failed because server is mid-shutdown
|
2018-12-17 16:34:32 +00:00
|
|
|
serverShuttingDown: data => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return data.connection.localize('actionhero.errors.serverShuttingDown')
|
|
|
|
},
|
|
|
|
|
|
|
|
// action failed because this client already has too many pending acitons
|
|
|
|
// limit defined in api.config.general.simultaneousActions
|
2018-12-17 16:34:32 +00:00
|
|
|
tooManyPendingActions: data => {
|
|
|
|
return data.connection.localize(
|
|
|
|
'actionhero.errors.tooManyPendingActions'
|
|
|
|
)
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dataLengthTooLarge: (maxLength, receivedLength) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return api.i18n.localize([
|
|
|
|
'actionhero.errors.dataLengthTooLarge',
|
|
|
|
{ maxLength: maxLength, receivedLength: receivedLength }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// ///////////////
|
|
|
|
// FILE SERVER //
|
|
|
|
// ///////////////
|
|
|
|
|
|
|
|
// The body message to accompany 404 (file not found) errors regarding flat files
|
|
|
|
// You may want to load in the contnet of 404.html or similar
|
2018-12-17 16:34:32 +00:00
|
|
|
fileNotFound: connection => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return connection.localize(['actionhero.errors.fileNotFound'])
|
|
|
|
},
|
|
|
|
|
|
|
|
// user didn't request a file
|
2018-12-17 16:34:32 +00:00
|
|
|
fileNotProvided: connection => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return connection.localize('actionhero.errors.fileNotProvided')
|
|
|
|
},
|
|
|
|
|
|
|
|
// something went wrong trying to read the file
|
|
|
|
fileReadError: (connection, error) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return connection.localize([
|
|
|
|
'actionhero.errors.fileReadError',
|
|
|
|
{ error: String(error) }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// ///////////////
|
|
|
|
// CONNECTIONS //
|
|
|
|
// ///////////////
|
|
|
|
|
|
|
|
verbNotFound: (connection, verb) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return connection.localize([
|
|
|
|
'actionhero.errors.verbNotFound',
|
|
|
|
{ verb: verb }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
verbNotAllowed: (connection, verb) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return connection.localize([
|
|
|
|
'actionhero.errors.verbNotAllowed',
|
|
|
|
{ verb: verb }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
connectionRoomAndMessage: connection => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return connection.localize('actionhero.errors.connectionRoomAndMessage')
|
|
|
|
},
|
|
|
|
|
|
|
|
connectionNotInRoom: (connection, room) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return connection.localize([
|
|
|
|
'actionhero.errors.connectionNotInRoom',
|
|
|
|
{ room: room }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
connectionAlreadyInRoom: (connection, room) => {
|
2018-12-17 16:34:32 +00:00
|
|
|
return connection.localize([
|
|
|
|
'actionhero.errors.connectionAlreadyInRoom',
|
|
|
|
{ room: room }
|
|
|
|
])
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
connectionRoomHasBeenDeleted: room => {
|
|
|
|
return api.i18n.localize(
|
|
|
|
'actionhero.errors.connectionRoomHasBeenDeleted'
|
|
|
|
)
|
2018-02-27 12:16:17 +00:00
|
|
|
},
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
connectionRoomNotExist: room => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return api.i18n.localize('actionhero.errors.connectionRoomNotExist')
|
|
|
|
},
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
connectionRoomExists: room => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return api.i18n.localize('actionhero.errors.connectionRoomExists')
|
|
|
|
},
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
connectionRoomRequired: room => {
|
2018-02-27 12:16:17 +00:00
|
|
|
return api.i18n.localize('actionhero.errors.connectionRoomRequired')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|