Gracefully opening secrets with exit on failure
This commit is contained in:
parent
ca8217b195
commit
637f51f0be
@ -1,3 +1,12 @@
|
||||
import sys
|
||||
|
||||
def return_credentials(path: str)->str:
|
||||
with open (path) as file:
|
||||
return file.read().strip()
|
||||
try:
|
||||
with open (path) as file:
|
||||
return file.read().strip()
|
||||
except FileNotFoundError:
|
||||
print(f"[FATAL] Secret file not found: {path}")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"[FATAL] Failed to read secret file {path}: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user