Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 5x 5x 5x 1x 1x 1x 5x 4x 4x 1x 4x 1x 4x 1x 4x 1x 4x 4x 193x 193x | import { todo_addEmailAddress as addEmailAddress } from '@clevercloud/client/esm/api/v2/user.js';
import { defineCommand } from '../../lib/define-command.js';
import { Logger } from '../../logger.js';
import { sendToApi } from '../../models/send-to-api.js';
import { emailArg } from './emails.args.js';
export const emailsAddCommand = defineCommand({
description: 'Add a new secondary email address to the current user',
since: '3.13.0',
options: {},
args: [emailArg],
async handler(_options, secondaryAddress) {
const secondaryAddressEncoded = encodeURIComponent(secondaryAddress);
try {
await addEmailAddress({ email: secondaryAddressEncoded }).then(sendToApi);
Logger.printSuccess(
`The server sent a confirmation email to ${secondaryAddress} to validate your secondary address`,
);
} catch (e) {
switch (e?.responseBody?.id) {
case 101:
throw new Error('This address already belongs to your account');
case 550:
throw new Error('The format of this address is invalid');
case 1004:
throw new Error('This address belongs to another account');
default:
throw e;
}
}
},
});
|