Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 0d661e4

Browse files
refactor: remove error code logs for failure ones
1 parent 803844b commit 0d661e4

5 files changed

Lines changed: 11 additions & 99 deletions

File tree

ERROR_CODES.md

Lines changed: 0 additions & 79 deletions
This file was deleted.

utils/file.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "fs";
22
import YAML from "yaml";
33
import { extname } from "path";
44
import { ROSIE_SUPPORTED_SUFFIX_TO_LANGUAGE } from "./constants";
5-
import { printError } from "./print";
5+
import { printFailure } from "./print";
66

77
/**
88
* read a file contents
@@ -14,7 +14,7 @@ export function readFile(path) {
1414
const file = fs.readFileSync(path, "utf8");
1515
return file;
1616
} catch (err) {
17-
printError(`unable to read file: ${path}`, "004");
17+
printFailure(`Unable to read file: ${path}`);
1818
process.exit(1);
1919
}
2020
}
@@ -29,7 +29,7 @@ export function parseYamlFile(content, path) {
2929
const parsedFile = YAML.parse(content);
3030
return parsedFile;
3131
} catch (err) {
32-
printError(`unable to parse YAML file${path ? `: ${path}` : ""}`, "005");
32+
printFailure(`Unable to parse YAML file${path ? `: ${path}` : ""}`);
3333
process.exit(1);
3434
}
3535
}

utils/git.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import child_process from "child_process";
2-
import { printError } from "./print";
2+
import { printFailure } from "./print";
33

44
/**
55
* Executes a git command with the given args in that order
@@ -14,8 +14,6 @@ export function executeGitCommand(args) {
1414
} catch (err) {
1515
// console.debug(err)
1616
return null;
17-
// printError("unable to execute a git command", "003");
18-
// process.exit(2);
1917
}
2018
}
2119

@@ -28,7 +26,9 @@ export function getRootDirectory() {
2826
if (rootDirectory) {
2927
return rootDirectory.split("\n").join("");
3028
} else {
31-
printError("unable to execute a git command", "003");
29+
printFailure(
30+
"Unable to execute a git command because you're not in a git repository"
31+
);
3232
process.exit(1);
3333
}
3434
}

utils/print.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ export function printEmptyLine() {
77
console.log("");
88
}
99

10-
/**
11-
* Used to print an error code and message for errors that need more explanation
12-
* @param {string} text
13-
* @param {string} code
14-
*/
15-
export function printError(text, code) {
16-
console.error(`%s: ${text}`, chalk.red.bold(`ERROR (${code})`));
17-
}
18-
1910
/**
2011
* Used to indicate something negative and needs the user's attention
2112
* @param {string} text

utils/rulesets.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { codigaApiFetch } from "./api";
33
import { ACTION_TOKEN_ADD, CODIGA_CONFIG_FILE } from "./constants";
44
import { getRootDirectory } from "./git";
55
import { GET_RULESETS_FOR_CLIENT } from "../graphql/queries";
6-
import { printCommandSuggestion, printError } from "./print";
6+
import { printCommandSuggestion, printFailure } from "./print";
77

88
/**
99
* Gets an array of rulesets and their rules
@@ -16,7 +16,7 @@ export async function getRulesetsWithRules(names) {
1616
return rulesetsWithRules;
1717
} catch (err) {
1818
// console.debug(err);
19-
printError("Unable to fetch your rulesets", "008");
19+
printFailure("We were unable to fetch your rulesets");
2020
printCommandSuggestion(
2121
" ↳ Set a Codiga API token with one of the following commands:",
2222
ACTION_TOKEN_ADD
@@ -39,13 +39,13 @@ export function getRulesetsFromCodigaFile() {
3939

4040
// if there isn't a rulesets value in the codiga.yml file, throw an error
4141
if (!parsedFile) {
42-
printError("no rulesets value found in codiga.yml", "006");
42+
printFailure("No rulesets value found in your `codiga.yml` file");
4343
process.exit(1);
4444
}
4545

4646
// if there aren't any ruleset items under `rulesets:` in the codiga.yml file, throw an error
4747
if (!parsedFile.rulesets) {
48-
printError("no rulesets found in codiga.yml", "007");
48+
printFailure("No rulesets found in your `codiga.yml` file");
4949
process.exit(1);
5050
}
5151

0 commit comments

Comments
 (0)