cubash-archive/lib/errors.js

304 lines
7.1 KiB
JavaScript

let Errors = {
unknown: [
'Uh oh! Something went wrong. Please contact a Kaverti staff member for assistance.',
500
],
accountAlreadyCreated: [
'This account has already been created',
400
],
categoryAlreadyExists: [
'This category has already been created',
400
],
ReadOnlyMode: [
'You may not perform this action while in Read-Only mode.',
400
],
teamBanned: [
'This team is banned and cannot be interacted with or viewed.',
400
],
notInTeam: [
'You need to be in this Team to do that action.',
400
],
noLongerHiringModerators: [
'We are no longer hiring moderators',
400
],
teamPermissions: [
'You do not have the required roles/permissions to perform this action.',
401
],
friendRequestAlreadySent: [
'You have already sent a friend request to this person, or you are currently friends.',
400
],
marketplaceNotFound: [
'We could not find your requested Marketplace resource',
400
],
uploadFile: [
'Please upload a file',
400
],
marketplaceAdminOnly: [
'Only admins can perform this action in the Marketplace',
401
],
unowned: [
'Marketplace item is unowned or doesn\'t exist',
400
],
needToBeFriend: [
'You need to be friends with this person to do this action.',
401
],
teamDoesNotExist: [
'This team does not exist.',
400
],
itemUnavailable: [
'This item is currently unavailable at this time.',
400
],
joinedTeam: [
'You are already in this Team',
400
],
LoginRequired: [
'Due to the nature of this action, a login is required.',
401
],
insufficientKoins: [
'Insufficient Koins to complete this transaction.',
400
],
deniedExperiments: [
'Please enable integration developer mode to access Remote experiments.',
401
],
reCAPTCHA: [
'Oh uh! You failed the reCAPTCHA score, please try again or contact support! This could be caused because you are operating the API through an unofficial client, CLI application, or reCAPTCHA is blocked by your network administrator or ISP.',
400
],
containsProfanityGeneric: [
'Please remove profanity from your input',
400
],
deniedWebsiteAccess: [
'This category has already been created',
400
],
maintenance: [
'Kaverti is currently under routine maintenance, website access has been restricted, please try again later.',
400
],
inviteOnly: [
'This Team is invite only',
401
],
unableToUpdateRole: [
'You cannot update this role',
400
],
invalidInvite: [
'This Team invite is invalid.',
401
],
accountDoesNotExist: [
'This account does not exist',
400
],
botOnlyEndpoint: [
'This endpoint is only available for bot accounts.'
],
invalidCategory: [
'This category does not exist',
400
],
invalidItem: [
'This Marketplace item has either been deleted or doesn\'t exist.',
400
],
offSale: [
'This Marketplace item is off sale and is unable to be purchased at this time.',
400
],
itemOwned: [
'You already own this item',
400
],
itemOwnedLimited: [
'You already own this item, however this is an item that can be sold, so if you no longer want the item, you can sell it from the item page or from within your inventory, this is a Limited Edition item exclusive',
400
],
invalidLoginCredentials: [
'The username or password provided was incorrect',
401
],
requestNotAuthorized: [
'You aren\'t logged in, or you don\'t have permission to perform this action.',
401
],
verifyEmail: [
'You need to verify your email first before you can use this Kaverti feature.',
401
],
invalidToken: [
'Your QACT (Quick Admin Creation Token) is invalid.',
401
],
passwordResetOptOut: [
'User has opted out of password resets.',
401
],
invalidPasswordToken: [
'This account recovery token is invalid.',
401
],
passwordResetDisabled: [
'This account has password resets disabled (This account has already reset their password, or hasn\'t ever reset their password.).',
401
],
featureDisabled: [
'This feature has been disabled, or is coming soon.',
401
],
featureDisabledState: [
'Administrators can no longer modify state. [Feature Disabled]',
401
],
noLongerHiring: [
'Sorry! We\'re no longer hiring staff right now.',
401
],
invalidPassKey: [
'Your PassKey is invalid.',
401
],
invalidEmailToken: [
'Your email token is invalid.',
401
],
alreadyVerified: [
'You have already verified your email.',
401
],
modifyAdminUser: [
'You cannot edit admin users.',
401
],
noSettings: [
'This Kaverti node has been incorrectly configured.',
500
],
registrationsDisabled: [
'Registrations are disabled, Kaverti is using PassKey\'s, if you would like an registration URL, please boost the Kaverti Discord server, If you think this was a mistake please contact an Kaverti administrator.',
400
],
selectCategory: [
'Please select a category.',
400
],
sessionAdminProtection: [
'You aren\'t logged in, you don\'t have permission to perform this action, or your session is an admin session, but you aren\'t an admin in the database, this is usually caused by a session error, and can occur when your privileges were updated while your session was active, please logout and back in to refresh your session. This security measure was implemented in API version 0.173.',
400
],
renderingFailure: [
'Something went wrong rendering your avatar, please try again later, or contact a Kaverti staff member.',
500
],
koinFail: [
'You can only get Koins from this method once a day.',
400
],
koinLimit: [
'I don\'t know how you did it, but you did, you managed to reach the Kave' + 'rti Koin limit, how is that possible? Who knows.',
400
],
lockedCategory: [
'This category is locked, only admins can post here, however, you can still respond to existing threads if they aren\'t locked',
400
],
userWallOptOut: [
'User has opted out of user walls',
400
],
passwordSame: [
'The passwords you entered are identical',
400
],
cannotLikeOwnPost: [
'You can\'t like your own post',
400
],
threadLocked: [
'Uh, You can\'t reply to a locked thread, bruh.',
400
],
threadTitleMaxLimit: [
'Thread title is over 50 characters.',
400
],
passwordTokenExpiry: [
'This password token has expired.',
400
],
postRemoved: [
'The original posters must\'ve deleted their post, so you cannot respond to it!',
400
]
}
function processErrors(errorName) {
let arr = Errors[errorName]
temp = {}
temp.name = errorName
temp.message = arr[0]
temp.status = arr[1]
return {
name: errorName,
message: arr[0],
status: arr[1]
}
}
let ProcessedErrors = {}
for(let errorName in Errors) {
ProcessedErrors[errorName] = processErrors(errorName)
}
ProcessedErrors.VALIDATION_ERROR = 'VALIDATION_ERROR';
ProcessedErrors.invalidParameter = function (param, message) {
let punctuatedMessage = '';
if(message) {
punctuatedMessage = ': ' + message;
}
return {
name: 'invalidParameter',
message: `${param} is invalid${punctuatedMessage}`,
status: 400,
parameter: param
};
}
ProcessedErrors.sequelizeValidation = (sequelize, obj) => {
return new sequelize.ValidationError(obj.error, [
new sequelize.ValidationErrorItem(
obj.error,
'Validation error',
obj.path,
obj.value
)
])
}
module.exports = ProcessedErrors