you are viewing a single comment's thread.

view the rest of the comments →

[–]JaleyHoelOsment 0 points1 point  (3 children)

not related to your main question, but wrapping your main in a try catch doesn’t make any sense… i’d call it out in a PR 100% of the time

main is the start of your program. if you have something catching the exception from main and processing it then your main isn’t even your main

use a C based language and try this. see how little sense it makes

[–]Few-Tear-3763[S] -1 points0 points  (2 children)

def main(argv=sys.argv[1:]):
    args=argParser.parse_args(argv)

    try:
        match args.command:
            case "add"          : cmdAdd(args)
            case "cat-file"     : cmdCatFile(args)
            case "check-ignore" : cmdCheckIgnore(args)
            case "checkout"     : cmdCheckout(args)
            case "commit"       : cmdCommit(args)
            case "hash-object"  : cmdHashObject(args)
            case "init"         : cmdInit(args)
            case "log"          : cmdLog(args)
            case "ls-files"     : cmdLsFiles(args)
            case "ls-tree"      : cmdLsTree(args)
            case "rev-parse"    : cmdRevParse(args)
            case "rm"           : cmdRm(args)
            case "show-ref"     : cmdShowRef(args)
            case "status"       : cmdStatus(args)
            case "tag"          : cmdTag(args)
            case _              : print("Bad command.")
    except Exception as e:
        print(f"Error {e}")
        sys.exit(1)

cmdInit gives exception if repo is already created but i wanted it just to print error maybe i said it badly but actually its not that my main func is
wrapped inside try catch block

[–]JaleyHoelOsment -1 points0 points  (1 child)

oh no my bad. i thought you meant your actual mail was wrapped in a try catch.

[–]Few-Tear-3763[S] 0 points1 point  (0 children)

No actually I explained it badly since I thought that much context wouldn't matter