Overhaul error handling
This commit is contained in:
		| @@ -15,8 +15,9 @@ response = requests.get(complete_url) | ||||
|  | ||||
| data = response.json() | ||||
|  | ||||
| if response.status_code == 200: | ||||
|  | ||||
| print() | ||||
| match response.status_code: | ||||
|     case 200: | ||||
|         info_main           = data["main"] | ||||
|         info_weather        = data["weather"] | ||||
|         current_temperature = info_main["temp"] | ||||
| @@ -24,7 +25,6 @@ if response.status_code == 200: | ||||
|         current_humidity    = info_main["humidity"] | ||||
|         weather_description = info_weather[0]["description"] | ||||
|  | ||||
|     print() | ||||
|         print(Columns([ | ||||
|             Panel(f"[blue]{round(current_temperature - 273.15, 2)}°C", | ||||
|                   title="[bold]Temperature[/bold]"), | ||||
| @@ -39,6 +39,7 @@ if response.status_code == 200: | ||||
|                   title="[bold]Description[/bold]"), | ||||
|         ])) | ||||
|  | ||||
| else: | ||||
|     print(f"Fehler: {response.status_code}") | ||||
|     print(response.text) | ||||
|     case _: | ||||
|         print(Panel(data["message"], | ||||
|             title=f"[bold red]Error: {response.status_code}", | ||||
|             expand=False)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user