|
1 | 1 | // @ts-check |
| 2 | + |
2 | 3 | import axios from "axios"; |
3 | 4 | import toEmoji from "emoji-name-map"; |
4 | 5 | import wrap from "word-wrap"; |
5 | 6 | import { themes } from "../../themes/index.js"; |
6 | | - |
7 | | -const TRY_AGAIN_LATER = "Please try again later"; |
8 | | - |
9 | | -const SECONDARY_ERROR_MESSAGES = { |
10 | | - MAX_RETRY: |
11 | | - "You can deploy own instance or wait until public will be no longer limited", |
12 | | - NO_TOKENS: |
13 | | - "Please add an env variable called PAT_1 with your GitHub API token in vercel", |
14 | | - USER_NOT_FOUND: "Make sure the provided username is not an organization", |
15 | | - GRAPHQL_ERROR: TRY_AGAIN_LATER, |
16 | | - GITHUB_REST_API_ERROR: TRY_AGAIN_LATER, |
17 | | - WAKATIME_USER_NOT_FOUND: "Make sure you have a public WakaTime profile", |
18 | | -}; |
19 | | - |
20 | | -/** |
21 | | - * Custom error class to handle custom GRS errors. |
22 | | - */ |
23 | | -class CustomError extends Error { |
24 | | - /** |
25 | | - * @param {string} message Error message. |
26 | | - * @param {string} type Error type. |
27 | | - */ |
28 | | - constructor(message, type) { |
29 | | - super(message); |
30 | | - this.type = type; |
31 | | - this.secondaryMessage = SECONDARY_ERROR_MESSAGES[type] || type; |
32 | | - } |
33 | | - |
34 | | - static MAX_RETRY = "MAX_RETRY"; |
35 | | - static NO_TOKENS = "NO_TOKENS"; |
36 | | - static USER_NOT_FOUND = "USER_NOT_FOUND"; |
37 | | - static GRAPHQL_ERROR = "GRAPHQL_ERROR"; |
38 | | - static GITHUB_REST_API_ERROR = "GITHUB_REST_API_ERROR"; |
39 | | - static WAKATIME_ERROR = "WAKATIME_ERROR"; |
40 | | -} |
| 7 | +import { SECONDARY_ERROR_MESSAGES, TRY_AGAIN_LATER } from "./error.js"; |
41 | 8 |
|
42 | 9 | /** |
43 | 10 | * Auto layout utility, allows us to layout things vertically or horizontally with |
@@ -452,26 +419,6 @@ const noop = () => {}; |
452 | 419 | const logger = |
453 | 420 | process.env.NODE_ENV === "test" ? { log: noop, error: noop } : console; |
454 | 421 |
|
455 | | -/** |
456 | | - * Missing query parameter class. |
457 | | - */ |
458 | | -class MissingParamError extends Error { |
459 | | - /** |
460 | | - * Missing query parameter error constructor. |
461 | | - * |
462 | | - * @param {string[]} missedParams An array of missing parameters names. |
463 | | - * @param {string=} secondaryMessage Optional secondary message to display. |
464 | | - */ |
465 | | - constructor(missedParams, secondaryMessage) { |
466 | | - const msg = `Missing params ${missedParams |
467 | | - .map((p) => `"${p}"`) |
468 | | - .join(", ")} make sure you pass the parameters in URL`; |
469 | | - super(msg); |
470 | | - this.missedParams = missedParams; |
471 | | - this.secondaryMessage = secondaryMessage; |
472 | | - } |
473 | | -} |
474 | | - |
475 | 422 | /** |
476 | 423 | * Retrieve text length. |
477 | 424 | * |
@@ -620,8 +567,6 @@ export { |
620 | 567 | getCardColors, |
621 | 568 | wrapTextMultiline, |
622 | 569 | logger, |
623 | | - CustomError, |
624 | | - MissingParamError, |
625 | 570 | measureText, |
626 | 571 | lowercaseTrim, |
627 | 572 | chunkArray, |
|
0 commit comments