Skip to content

Commit

Permalink
fix: show error when environment exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Kürten committed May 29, 2024
1 parent ecb1e6f commit 1fbf8cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cfc/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import typer
from rich.console import Console
from rich.table import Table

from json import JSONDecodeError
from .config import config

NAME_PATTERN = r"^[^\-\.][\w\-\.]+$"
Expand Down Expand Up @@ -67,9 +67,11 @@ def create(name: str = typer.Argument(..., callback=name_callback)):
console.print("Environment successfully created")

elif response.status_code in (400, 500):
console.print(
"Error while creating environment: " + response.json()["detail"]["msg"]
)
try:
message = response.json().get("detail")
except JSONDecodeError:
message = response.text
console.print("Error while creating environment: " + message)
raise typer.Exit(code=1)

else:
Expand Down

0 comments on commit 1fbf8cf

Please sign in to comment.