Skip to content

Commit

Permalink
Strip down return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvogel committed Feb 11, 2025
1 parent ac716ba commit cbf5e09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/pyProfileMgr/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ def _add_profile(args) -> Ret.CODE:
profile_mgr = ProfileMgr()

if args.server is None:
ret_status = Ret.CODE.RET_ERROR_NO_SERVER_URL
ret_status = Ret.CODE.RET_ERROR_MISSING_SERVER_URL
LOG.print_error(PrintType.ERROR, ret_status)
elif args.token is None and (args.user is None or args.password is None):
ret_status = Ret.CODE.RET_ERROR_NO_USERINFORMATION
ret_status = Ret.CODE.RET_ERROR_MISSING_USER_INFORMATION
LOG.print_error(PrintType.ERROR, ret_status)
print("Profiles can only be created using login credentials." +
"Please provide a token using the --token option or --user/--password.")
Expand Down
55 changes: 21 additions & 34 deletions src/pyProfileMgr/ret.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,29 @@ class CODE(IntEnum):
RET_ERROR = 1
RET_ERROR_ARGPARSE = 2 # Must be 2 to match the argparse error code.
RET_ERROR_FILEPATH_INVALID = 3
RET_ERROR_WRONG_FILE_FORMAT = 4
RET_ERROR_ISSUE_NOT_FOUND = 5
RET_ERROR_FILE_OPEN_FAILED = 6
RET_ERROR_NO_USERINFORMATION = 7
RET_ERROR_PROFILE_NOT_FOUND = 8
RET_ERROR_NO_SERVER_URL = 9
RET_ERROR_CREATING_TICKET_FAILED = 10
RET_ERROR_INVALID_SEARCH = 11
RET_ERROR_INVALID_URL = 12
RET_ERROR_BOARD_NOT_FOUND = 14
RET_ERROR_PROFILE_ALREADY_EXISTS = 15
RET_ERROR_INVALID_PROFILE_TYPE = 16
RET_ERROR_MISSING_CREDENTIALS = 17
RET_ERROR_FILE_OPEN_FAILED = 4
RET_ERROR_MISSING_USER_INFORMATION = 5
RET_ERROR_MISSING_CREDENTIALS = 6
RET_ERROR_MISSING_SERVER_URL = 7
RET_ERROR_INVALID_PROFILE_TYPE = 8
RET_ERROR_PROFILE_NOT_FOUND = 9
RET_ERROR_PROFILE_ALREADY_EXISTS = 10

MSG = {
CODE.RET_OK: "Process successful.",
CODE.RET_ERROR: "Error occurred.",
CODE.RET_ERROR_ARGPARSE: "Error while parsing arguments.",
CODE.RET_ERROR_FILEPATH_INVALID: "The provided filepath does not exist.",
CODE.RET_ERROR_WRONG_FILE_FORMAT: "Wrong file format for save file provided.",
CODE.RET_ERROR_ISSUE_NOT_FOUND: "Jira issue not found.",
CODE.RET_ERROR_FILE_OPEN_FAILED: "Failed to open file.",
CODE.RET_ERROR_NO_USERINFORMATION: "No user information was provided " +
"or stored information file.",
CODE.RET_ERROR_PROFILE_NOT_FOUND: "The server profile does not exist.",
CODE.RET_ERROR_NO_SERVER_URL: "To add a new profile, the server url must " +
"be provided with the --url option",
CODE.RET_ERROR_CREATING_TICKET_FAILED: "creating the ticket on the Jira server failed",
CODE.RET_ERROR_INVALID_SEARCH: "search string returned a Jira error",
CODE.RET_ERROR_INVALID_URL: "The provided server url is invalid",
CODE.RET_ERROR_BOARD_NOT_FOUND: "The Jira board does not exist or " +
"you have no access to it.",
CODE.RET_ERROR_PROFILE_ALREADY_EXISTS: "The profile you want to add already exists.\n" +
"Use the 'update' command to update it.",
CODE.RET_ERROR_INVALID_PROFILE_TYPE: "The provided profile type is invalid.",
CODE.RET_ERROR_MISSING_CREDENTIALS: "Failed to provide server credentials.",
CODE.RET_OK: "Process successful.",
CODE.RET_ERROR: "Error occurred.",
CODE.RET_ERROR_ARGPARSE: "Error while parsing arguments.",
CODE.RET_ERROR_FILEPATH_INVALID: "The provided filepath does not exist.",
CODE.RET_ERROR_FILE_OPEN_FAILED: "Failed to open file.",
CODE.RET_ERROR_MISSING_USER_INFORMATION: "Missing user information was provided " +
"or not found in file.",
CODE.RET_ERROR_MISSING_CREDENTIALS: "Failed to provide server credentials.",
CODE.RET_ERROR_MISSING_SERVER_URL: "To add a new profile, the server url must " +
"be provided with the --server option",
CODE.RET_ERROR_INVALID_PROFILE_TYPE: "The provided profile type is invalid.",
CODE.RET_ERROR_PROFILE_NOT_FOUND: "The profile does not exist.",
CODE.RET_ERROR_PROFILE_ALREADY_EXISTS: "The profile you want to add already exists.\n" +
"Use the 'update' command to update it.",
}


Expand Down

0 comments on commit cbf5e09

Please sign in to comment.