Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same output/error handling for all functions #29

Open
patrikspiess opened this issue Mar 6, 2023 · 1 comment
Open

Same output/error handling for all functions #29

patrikspiess opened this issue Mar 6, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@patrikspiess
Copy link
Member

There are differences in the output/error handling for different commands:

  • fotoobo fgt get version presents the data in a nice table, even in the case of failure
  • fotoobo fmg get version will just print the error (in case of error), even no "Error"-panel
@patrikspiess patrikspiess added the enhancement New feature or request label Mar 6, 2023
@skftnt
Copy link
Contributor

skftnt commented Apr 13, 2023

Create a custom error class that inherits from the built-in Exception class. Would belong in /helpers. (error helper)

class CustomError(Exception):
    def __init__(self, error_message, error_type=None):
        self.error_message = error_message
        self.error_type = error_type

    def __str__(self):
        if self.error_type:
            return f"{self.error_type}: {self.error_message}"
        else:
            return self.error_message

# Example usage
try:
    # Your code that might raise an error
    raise CustomError("Error", "Error")
except CustomError as e:
    print(e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants