Skip to content

Commit

Permalink
Merge pull request #22 from AllanCapistrano/fix/bitly-limit-reach
Browse files Browse the repository at this point in the history
fix: handling bitly exception
  • Loading branch information
AllanCapistrano authored Jul 27, 2024
2 parents 5c54447 + 4d98a8d commit abb6bf0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions services/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from rich.table import Table as RichTable
from rich.progress import track
from rich.errors import NotRenderableError
from pyshorteners.exceptions import ShorteningErrorException

from .shortUrl import shorten_url

Expand All @@ -15,6 +16,7 @@ def __init__(self) -> None:

self.console = Console()
self.table = RichTable(show_lines=True)
self.__error_occurred__ = False
self.__create_table__()

def __create_table__(self) -> None:
Expand Down Expand Up @@ -74,14 +76,20 @@ def fill_table(
broadcasts[i],
)
except NotRenderableError as nre:
self.__error_occurred__ = True
print()
self.console.print(nre, style="bold red")

exit()
except ShorteningErrorException as sre:
self.__error_occurred__ = True
self.console.print("O limite de encurtamentos da Bitly foi alcançado.\n", style="bold red")


def show_table(self) -> None:
""" Exibe a tabela no terminal.
"""

print()
self.console.print(self.table)
if (not self.__error_occurred__):
print()
self.console.print(self.table)

0 comments on commit abb6bf0

Please sign in to comment.