1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const sdk_1 = require("@cto.ai/sdk");
|
5 | const errorSource_1 = require("../constants/errorSource");
|
6 | const env_1 = require("../constants/env");
|
7 | const ErrorTemplate_1 = require("./ErrorTemplate");
|
8 | const utils_1 = require("../utils");
|
9 | const debug_1 = tslib_1.__importDefault(require("debug"));
|
10 | const debug = debug_1.default('ops:CustomErrors');
|
11 | const expectedSource = {
|
12 | source: errorSource_1.errorSource.EXPECTED,
|
13 | };
|
14 | const { actionBlue, white, dim } = sdk_1.ux.colors;
|
15 | const problemContinues = `If the problem continues please contact us at: ${actionBlue(env_1.INTERCOM_EMAIL)}`;
|
16 | const tryAgainOrContact = `Please try again or contact ${actionBlue(env_1.INTERCOM_EMAIL)} and we'll do our best to help.`;
|
17 | class FileNotFoundError extends ErrorTemplate_1.ErrorTemplate {
|
18 | constructor(err, path, file) {
|
19 | super(white(`🤔 Looks like the file ${actionBlue(file)} wasn't found in path:\n ${actionBlue(path)}\n Please verify it exists and try again.`), err, expectedSource);
|
20 | }
|
21 | }
|
22 | exports.FileNotFoundError = FileNotFoundError;
|
23 | class DockerBuildImageError extends ErrorTemplate_1.ErrorTemplate {
|
24 | constructor(err) {
|
25 | super(white('🤔 Looks like there was an error when building your image.\n Please check your Dockerfile and try again.'), err, expectedSource);
|
26 | }
|
27 | }
|
28 | exports.DockerBuildImageError = DockerBuildImageError;
|
29 | class ConfigError extends ErrorTemplate_1.ErrorTemplate {
|
30 | constructor(err) {
|
31 | super(white(`❗️Uh-oh, we experienced a problem.\n Please try signing out and back in again.\n ${problemContinues}`), err, expectedSource);
|
32 | }
|
33 | }
|
34 | exports.ConfigError = ConfigError;
|
35 | class CopyTemplateFilesError extends ErrorTemplate_1.ErrorTemplate {
|
36 | constructor(err) {
|
37 | super(white(`❗We couldn't copy the required files.\n Please check your directory permissions.\n ${tryAgainOrContact}`), err, expectedSource);
|
38 | }
|
39 | }
|
40 | exports.CopyTemplateFilesError = CopyTemplateFilesError;
|
41 | class MandatoryParameter extends ErrorTemplate_1.ErrorTemplate {
|
42 | constructor(err) {
|
43 | super(white(`❗️Uh-oh, your request failed due to undefined parameters.\n ${tryAgainOrContact}`), err, expectedSource);
|
44 | }
|
45 | }
|
46 | exports.MandatoryParameter = MandatoryParameter;
|
47 | class UndefinedParameter extends ErrorTemplate_1.ErrorTemplate {
|
48 | constructor(err) {
|
49 | super('Missing parameter', err);
|
50 | }
|
51 | }
|
52 | exports.UndefinedParameter = UndefinedParameter;
|
53 | class UserUnauthorized extends ErrorTemplate_1.ErrorTemplate {
|
54 | constructor(err) {
|
55 | super(white("🤚 You don't have permissions for that action. Please try again."), err, expectedSource);
|
56 | }
|
57 | }
|
58 | exports.UserUnauthorized = UserUnauthorized;
|
59 | class CouldNotCreateOp extends ErrorTemplate_1.ErrorTemplate {
|
60 | constructor(err) {
|
61 | super(white('😅 Uh-oh, this op already exists, please remove it try again.'), err, expectedSource);
|
62 | }
|
63 | }
|
64 | exports.CouldNotCreateOp = CouldNotCreateOp;
|
65 | class CouldNotCreateWorkflow extends ErrorTemplate_1.ErrorTemplate {
|
66 | constructor(err) {
|
67 | super(white('😅 Uh-oh, this workflow already exists, please remove it try again.'), err, expectedSource);
|
68 | }
|
69 | }
|
70 | exports.CouldNotCreateWorkflow = CouldNotCreateWorkflow;
|
71 | class CouldNotInitializeOp extends ErrorTemplate_1.ErrorTemplate {
|
72 | constructor(err) {
|
73 | super(white(`❗️Looks like a problem occurred initializing your Op / Workflow.\n ${tryAgainOrContact}`), err, expectedSource);
|
74 | }
|
75 | }
|
76 | exports.CouldNotInitializeOp = CouldNotInitializeOp;
|
77 | class CouldNotGetRegistryToken extends ErrorTemplate_1.ErrorTemplate {
|
78 | constructor(err) {
|
79 | super(white('😅Call to registry/token failed, most likely due to invalid access token.'), err, expectedSource);
|
80 | }
|
81 | }
|
82 | exports.CouldNotGetRegistryToken = CouldNotGetRegistryToken;
|
83 | class CouldNotMakeDir extends ErrorTemplate_1.ErrorTemplate {
|
84 | constructor(err, path = '') {
|
85 | super(white(`😅 Looks like we weren't able to create a config directory at:\n ${actionBlue(path)}\n Please check your permissions and try again.`), err, expectedSource);
|
86 | }
|
87 | }
|
88 | exports.CouldNotMakeDir = CouldNotMakeDir;
|
89 | class InvalidTeamNameFormat extends ErrorTemplate_1.ErrorTemplate {
|
90 | constructor(err) {
|
91 | super(white(`❗ Sorry, that's an invalid team name. \n ❗ Team names may contain only letters (case-sensitive), numbers, dashes (-), and underscores (_).`), err, {
|
92 | source: errorSource_1.errorSource.EXPECTED,
|
93 | exit: false,
|
94 | });
|
95 | }
|
96 | }
|
97 | exports.InvalidTeamNameFormat = InvalidTeamNameFormat;
|
98 | class CouldNotGetLatestVersion extends ErrorTemplate_1.ErrorTemplate {
|
99 | constructor(err) {
|
100 | super('Call to check version failed, most likely due to internet connection.', err, {
|
101 | source: errorSource_1.errorSource.EXPECTED,
|
102 | exit: false,
|
103 | });
|
104 | }
|
105 | }
|
106 | exports.CouldNotGetLatestVersion = CouldNotGetLatestVersion;
|
107 | class APIError extends ErrorTemplate_1.ErrorTemplate {
|
108 | constructor(err) {
|
109 | super(white(`❗️ Looks like an API error occurred.\n ${tryAgainOrContact}`), err, expectedSource);
|
110 | }
|
111 | }
|
112 | exports.APIError = APIError;
|
113 | class AnalyticsError extends ErrorTemplate_1.ErrorTemplate {
|
114 | constructor(err) {
|
115 | super('Analytics error occurred', err, { exit: false });
|
116 | }
|
117 | }
|
118 | exports.AnalyticsError = AnalyticsError;
|
119 | class PermissionsError extends ErrorTemplate_1.ErrorTemplate {
|
120 | constructor(err) {
|
121 | super(white(`🤚 Uh-oh! You don't have permission to perform this action.\n Please review your system user permissions and try again.`), err, expectedSource);
|
122 | }
|
123 | }
|
124 | exports.PermissionsError = PermissionsError;
|
125 | class InviteSendingInvite extends ErrorTemplate_1.ErrorTemplate {
|
126 | constructor(err) {
|
127 | super(white('😅 Uh-oh, the invite failed to send. Please try again.'), err, expectedSource);
|
128 | }
|
129 | }
|
130 | exports.InviteSendingInvite = InviteSendingInvite;
|
131 | class InviteCodeInvalid extends ErrorTemplate_1.ErrorTemplate {
|
132 | constructor(err) {
|
133 | super(white("😅 Uh-oh, the invite code doesn't seem to be valid. Please check the code and try again."), err, expectedSource);
|
134 | }
|
135 | }
|
136 | exports.InviteCodeInvalid = InviteCodeInvalid;
|
137 | class InvalidInputCharacter extends ErrorTemplate_1.ErrorTemplate {
|
138 | constructor(fieldName) {
|
139 | super(white(`❗ The ${fieldName} can only contain numbers, letters, -, or _'.`), undefined, expectedSource);
|
140 | }
|
141 | }
|
142 | exports.InvalidInputCharacter = InvalidInputCharacter;
|
143 | class MissingRequiredArgument extends ErrorTemplate_1.ErrorTemplate {
|
144 | constructor(command) {
|
145 | super(white(`✋ This command requires an argument. Run ${utils_1.terminalText(`${command} --help`)} to learn more.`), undefined, expectedSource);
|
146 | }
|
147 | }
|
148 | exports.MissingRequiredArgument = MissingRequiredArgument;
|
149 | class NoResultsFoundForDeletion extends ErrorTemplate_1.ErrorTemplate {
|
150 | constructor(opOrWorkflow) {
|
151 | super(white(`🤔 We couldn't find any matches for ${actionBlue(opOrWorkflow)}.\n Please check the name and try again.`), undefined, expectedSource);
|
152 | }
|
153 | }
|
154 | exports.NoResultsFoundForDeletion = NoResultsFoundForDeletion;
|
155 | class DockerPublishNoImageFound extends ErrorTemplate_1.ErrorTemplate {
|
156 | constructor(opName, teamName) {
|
157 | super(white(`✋ We couldn't find an image for that ${actionBlue(opName)}.\n ⚙️ Please build this op for ${actionBlue(`${teamName}`)}: ${utils_1.terminalText(`ops build ${opName}`)}`), undefined, expectedSource);
|
158 | }
|
159 | }
|
160 | exports.DockerPublishNoImageFound = DockerPublishNoImageFound;
|
161 | class NoLocalOpsFound extends ErrorTemplate_1.ErrorTemplate {
|
162 | constructor() {
|
163 | super(white(`💩 We couldn't find any ops in the ops.yml!`), undefined, expectedSource);
|
164 | }
|
165 | }
|
166 | exports.NoLocalOpsFound = NoLocalOpsFound;
|
167 | class NoOpsFound extends ErrorTemplate_1.ErrorTemplate {
|
168 | constructor(opName) {
|
169 | super(white(`💩 We couldn't find any ops with the name ${opName}!`), undefined, expectedSource);
|
170 | }
|
171 | }
|
172 | exports.NoOpsFound = NoOpsFound;
|
173 | class NoWorkflowsFound extends ErrorTemplate_1.ErrorTemplate {
|
174 | constructor() {
|
175 | super(white(`💩 We couldn't find any workflows in the ops.yml!`), undefined, expectedSource);
|
176 | }
|
177 | }
|
178 | exports.NoWorkflowsFound = NoWorkflowsFound;
|
179 | class NoStepsFound extends ErrorTemplate_1.ErrorTemplate {
|
180 | constructor() {
|
181 | super(white(`💩 We couldn't find any workflow steps in the ops.yml!`), undefined, expectedSource);
|
182 | }
|
183 | }
|
184 | exports.NoStepsFound = NoStepsFound;
|
185 | class InvalidStepsFound extends ErrorTemplate_1.ErrorTemplate {
|
186 | constructor(step) {
|
187 | super(white(`💩 Workflow step: ${step} is invalid!`), undefined, expectedSource);
|
188 | }
|
189 | }
|
190 | exports.InvalidStepsFound = InvalidStepsFound;
|
191 | class ImageNotFoundError extends ErrorTemplate_1.ErrorTemplate {
|
192 | constructor(imageName) {
|
193 | super(white(`🤔 We couldn't find an image with the name ${actionBlue(imageName)}.\n Please select a different one and try again.`), undefined, expectedSource);
|
194 | }
|
195 | }
|
196 | exports.ImageNotFoundError = ImageNotFoundError;
|
197 | class SignInError extends ErrorTemplate_1.ErrorTemplate {
|
198 | constructor(err) {
|
199 | super(white(`🤔 Sorry, we couldn’t find an account with that email or password.\n Forgot your password? Run ${utils_1.terminalText('ops account:reset')}`), err, expectedSource);
|
200 | }
|
201 | }
|
202 | exports.SignInError = SignInError;
|
203 | class NoEmailForReset extends ErrorTemplate_1.ErrorTemplate {
|
204 | constructor(err, email) {
|
205 | super(white(`😞 Uh-oh, we couldn't find any user associated with ${actionBlue(email)}\n Please Check your email and try again.`), err, expectedSource);
|
206 | }
|
207 | }
|
208 | exports.NoEmailForReset = NoEmailForReset;
|
209 | class ResetTokenError extends ErrorTemplate_1.ErrorTemplate {
|
210 | constructor(err) {
|
211 | super(white(`😅 Looks like there's an issue with that token.\n Please request a new token by running ${utils_1.terminalText('ops account:reset')}`), err, expectedSource);
|
212 | }
|
213 | }
|
214 | exports.ResetTokenError = ResetTokenError;
|
215 | class SignUpError extends ErrorTemplate_1.ErrorTemplate {
|
216 | constructor(err) {
|
217 | super(white(`😅 We couldn't sign you up at this point in time.\n ${tryAgainOrContact}`), err, expectedSource);
|
218 | }
|
219 | }
|
220 | exports.SignUpError = SignUpError;
|
221 | class ImageTagError extends ErrorTemplate_1.ErrorTemplate {
|
222 | constructor(err) {
|
223 | super('❗️ Could not tag image.', err);
|
224 | }
|
225 | }
|
226 | exports.ImageTagError = ImageTagError;
|
227 | class ImagePushError extends ErrorTemplate_1.ErrorTemplate {
|
228 | constructor(err) {
|
229 | super('❗️ Could not push image.', err);
|
230 | }
|
231 | }
|
232 | exports.ImagePushError = ImagePushError;
|
233 | class AlreadySignedOut extends ErrorTemplate_1.ErrorTemplate {
|
234 | constructor() {
|
235 | super(white(`🤷♂️ Looks like you are already signed out.\n Run ${utils_1.terminalText('ops account:signin')} to sign back into your account.`), undefined, expectedSource);
|
236 | }
|
237 | }
|
238 | exports.AlreadySignedOut = AlreadySignedOut;
|
239 | class SignOutError extends ErrorTemplate_1.ErrorTemplate {
|
240 | constructor(err) {
|
241 | super(white(`😅 Uh-oh, we weren't able to sign out up at this point in time.\n ${tryAgainOrContact}`), err, expectedSource);
|
242 | }
|
243 | }
|
244 | exports.SignOutError = SignOutError;
|
245 | class YamlPortError extends ErrorTemplate_1.ErrorTemplate {
|
246 | constructor(badPort) {
|
247 | super(white(`🤔 We're having trouble parsing the port: ${badPort}.\n ${dim('Please enter with the format')} ${actionBlue('{HostPort}:{InternalPort}')}${dim('. For example:')} ${actionBlue('3000:3000')}`), undefined, expectedSource);
|
248 | }
|
249 | }
|
250 | exports.YamlPortError = YamlPortError;
|
251 | class SSOError extends ErrorTemplate_1.ErrorTemplate {
|
252 | constructor(message) {
|
253 | message && debug(message);
|
254 | super(white(`🤔 We're having trouble signing you in. Please try running ${actionBlue('$ ops account:signin')} again!`), undefined, expectedSource);
|
255 | }
|
256 | }
|
257 | exports.SSOError = SSOError;
|
258 | class TokenExpiredError extends ErrorTemplate_1.ErrorTemplate {
|
259 | constructor() {
|
260 | super(white(`\n⚠️ Sorry your session has expired. \n\n 👨💻 You can sign in with ${sdk_1.ux.colors.green('$')} ${sdk_1.ux.colors.callOutCyan('ops account:signin')}`), undefined, expectedSource);
|
261 | }
|
262 | }
|
263 | exports.TokenExpiredError = TokenExpiredError;
|
264 | class CannotDeleteOps extends ErrorTemplate_1.ErrorTemplate {
|
265 | constructor(err) {
|
266 | super(white(`❗ Sorry, we cannot delete the op. \n\n Please verify that it is not being used in some other op.\n`), err, expectedSource);
|
267 | }
|
268 | }
|
269 | exports.CannotDeleteOps = CannotDeleteOps;
|
270 | class InvalidOpName extends ErrorTemplate_1.ErrorTemplate {
|
271 | constructor() {
|
272 | super(white(`❗ Sorry, we cannot find that op. Please enter an op with the format:\n- ${sdk_1.ux.colors.bold('@teamName')}/${sdk_1.ux.colors.cyan('opName')}\n- ${sdk_1.ux.colors.cyan('opName')}: for ops you have in your team, or a folder in your current working directory`), undefined, expectedSource);
|
273 | }
|
274 | }
|
275 | exports.InvalidOpName = InvalidOpName;
|
276 | class UnauthorizedtoAccessOp extends ErrorTemplate_1.ErrorTemplate {
|
277 | constructor(err) {
|
278 | super(white(`❗ Oops, seems like you do not have access to run this op!`), err, expectedSource);
|
279 | }
|
280 | }
|
281 | exports.UnauthorizedtoAccessOp = UnauthorizedtoAccessOp;
|
282 | class IncompleteOpsYml extends ErrorTemplate_1.ErrorTemplate {
|
283 | constructor(message) {
|
284 | super(white(`❗ Sorry, we have difficulty parsing your ops.yml. ${message}`), undefined, expectedSource);
|
285 | }
|
286 | }
|
287 | exports.IncompleteOpsYml = IncompleteOpsYml;
|