File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 1616import toml
1717import semver
1818
19+ from simvue .exception import SimvueUserConfigError
1920import simvue .utilities as sv_util
2021from simvue .config .parameters import (
2122 ClientGeneralOptions ,
@@ -221,10 +222,10 @@ def fetch(
221222 _run_mode = mode or _config_dict ["run" ].get ("mode" ) or "online"
222223
223224 if not _server_url and _run_mode != "offline" :
224- raise RuntimeError ("No server URL was specified" )
225+ raise SimvueUserConfigError ("No server URL was specified" )
225226
226227 if not _server_token and _run_mode != "offline" :
227- raise RuntimeError ("No server token was specified" )
228+ raise SimvueUserConfigError ("No server token was specified" )
228229
229230 _config_dict ["server" ]["token" ] = _server_token
230231 _config_dict ["server" ]["url" ] = _server_url
Original file line number Diff line number Diff line change @@ -22,3 +22,9 @@ class SimvueRunError(RuntimeError):
2222 """A special sub-class of runtime error specifically for Simvue run errors"""
2323
2424 pass
25+
26+
27+ class SimvueUserConfigError (Exception ):
28+ """Raised when no local Simvue Configuration file has been found."""
29+
30+ pass
Original file line number Diff line number Diff line change 3333from simvue .api .objects .alert .fetch import Alert
3434from simvue .api .objects .folder import Folder
3535from simvue .api .objects .grids import GridMetrics
36- from simvue .exception import ObjectNotFoundError , SimvueRunError
36+ from simvue .exception import ObjectNotFoundError , SimvueRunError , SimvueUserConfigError
3737from simvue .utilities import prettify_pydantic
3838
3939
@@ -184,9 +184,14 @@ def __init__(
184184 self ._data : dict [str , typing .Any ] = {}
185185 self ._step : int = 0
186186 self ._active : bool = False
187- self ._user_config : SimvueConfiguration = SimvueConfiguration .fetch (
188- server_url = server_url , server_token = server_token , mode = mode
189- )
187+
188+ try :
189+ self ._user_config : SimvueConfiguration = SimvueConfiguration .fetch (
190+ server_url = server_url , server_token = server_token , mode = mode
191+ )
192+ except SimvueUserConfigError as e :
193+ click .secho (f"[simvue] { e } " , bold = True , fg = "red" )
194+ sys .exit (1 )
190195
191196 logging .getLogger (self .__class__ .__module__ ).setLevel (
192197 logging .DEBUG
You can’t perform that action at this time.
0 commit comments