Repository: Agenta-AI/agenta
Issue: Improve error when running agenta serve with the server down

**Is your feature request related to a problem? Please describe.**
Currently if you run agenta variant serve and the server is down, you get a long obfuscated error

**To reproduce**
Shut down the docker-compose then run agenta serve. You will get this error

```
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-2 baby_name_generator % agenta variant serve
Traceback (most recent call last):
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connection.py", line 200, in _new_conn
    sock = connection.create_connection(
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connection.py", line 388, in request
    self.endheaders()
  File "/Users/mahmoudmabrouk/opt/anaconda3/lib/python3.9/http/client.py", line 1274, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/mahmoudmabrouk/opt/anaconda3/lib/python3.9/http/client.py", line 1034, in _send_output
    self.send(msg)
  File "/Users/mahmoudmabrouk/opt/anaconda3/lib/python3.9/http/client.py", line 974, in send
    self.connect()
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connection.py", line 236, in connect
    self.sock = self._new_conn()
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connection.py", line 215, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fed2071d250>: Failed to establish a new connection: [Errno 61] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /api/app_variant/list_variants/?app_name=babyname (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fed2071d250>: Failed to establish a new connection: [Errno 61] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/bin/agenta", line 6, in <module>
    sys.exit(cli())
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/mahmoudmabrouk/agenta/code/agenta-core/agenta-cli/agenta/cli/variant_commands.py", line 242, in serve_cli
    config_check(app_folder)
  File "/Users/mahmoudmabrouk/agenta/code/agenta-core/agenta-cli/agenta/cli/variant_commands.py", line 212, in config_check
    helper.update_config_from_backend(config_file, host=host)
  File "/Users/mahmoudmabrouk/agenta/code/agenta-core/agenta-cli/agenta/cli/helper.py", line 37, in update_config_from_backend
    config = update_variants_from_backend(app_name, config, host)
  File "/Users/mahmoudmabrouk/agenta/code/agenta-core/agenta-cli/agenta/cli/helper.py", line 21, in update_variants_from_backend
    variants: List[AppVariant] = client.list_variants(app_name, host)
  File "/Users/mahmoudmabrouk/agenta/code/agenta-core/agenta-cli/agenta/client/client.py", line 63, in list_variants
    response = requests.get(f"{host}/{BACKEND_URL_SUFFIX}/app_variant/list_variants/?app_name={app_name}", timeout=600)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /api/app_variant/list_variants/?app_name=babyname (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fed2071d250>: Failed to establish a new connection: [Errno 61] Connection refused'))
```


**Describe the solution you'd like**
We need to provide better exception handling, so that when this happens the user gets a message explaining the issue (failed to connect to agenta backend) and some pointers for the solution (check that the backend is working, restart docker compose)


Changed files:
agenta-cli/agenta/cli/variant_commands.py

diff --git a/agenta-cli/agenta/cli/variant_commands.py b/agenta-cli/agenta/cli/variant_commands.py
index 9f3cb67..334b86b 100644
--- a/agenta-cli/agenta/cli/variant_commands.py
+++ b/agenta-cli/agenta/cli/variant_commands.py
@@ -3,6 +3,8 @@ import sys
 from pathlib import Path
 from typing import List
 
+from requests.exceptions import ConnectionError
+
 import click
 import questionary
 import toml
@@ -259,11 +261,19 @@ def remove_variant_cli(variant_name: str, app_folder: str):
 @click.option('--file_name', default='app.py', help="The name of the file to run")
 def serve_cli(app_folder: str, file_name: str):
     """Adds a variant to the web ui and serves the api locally."""
-    config_check(app_folder)
-    host = get_host(app_folder)
-    variant_name = add_variant(variant_name='', app_folder=app_folder, file_name=file_name, host=host)
-    if variant_name:  # otherwise we either failed or we were doing an update and we don't need to manually start the variant!!
-        start_variant(variant_name=variant_name, app_folder=app_folder, host=host)
+    try:
+        config_check(app_folder)
+        host = get_host(app_folder)
+        variant_name = add_variant(variant_name='', app_folder=app_folder, file_name=file_name, host=host)
+        if variant_name:  # otherwise we either failed or we were doing an update and we don't need to manually start the variant!!
+            start_variant(variant_name=variant_name, app_folder=app_folder, host=host)
+    except ConnectionError:
+        error_msg = "Failed to connect to Agenta backend. Here's how you can solve the issue:\\n"
+        error_msg += "- First, please ensure that the backend service is running and accessible.\\n"
+        error_msg += "- Second, try restarting the containers (if using Docker Compose)."
+        click.echo(click.style(f"{error_msg}", fg='red'))
+    except Exception as e:
+        click.echo(click.style(f"Error message: {str(e)}", fg="red"))
 
 
 @variant.command(name='list')