Skip to content

Commit eb9e2f4

Browse files
authored
Merge pull request #166 from splunk/add_verbose_error_option
Add verbose error option
2 parents d94aa7b + a16e88a commit eb9e2f4

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

contentctl/contentctl.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
from contentctl.actions.initialize import Initialize
1+
import traceback
2+
import sys
3+
import warnings
4+
import pathlib
25
import tyro
6+
7+
from contentctl.actions.initialize import Initialize
38
from contentctl.objects.config import init, validate, build, new, deploy_acs, deploy_rest, test, test_servers, inspect, report, test_common, release_notes
49
from contentctl.actions.validate import Validate
510
from contentctl.actions.new_content import NewContent
@@ -9,14 +14,10 @@
914
DirectorOutputDto,
1015
Build,
1116
)
12-
1317
from contentctl.actions.test import Test
1418
from contentctl.actions.test import TestInputDto
1519
from contentctl.actions.reporting import ReportingInputDto, Reporting
1620
from contentctl.actions.inspect import Inspect
17-
import sys
18-
import warnings
19-
import pathlib
2021
from contentctl.input.yml_reader import YmlReader
2122
from contentctl.actions.release_notes import ReleaseNotes
2223

@@ -183,7 +184,7 @@ def main():
183184

184185

185186

186-
187+
config = None
187188
try:
188189
# Since some model(s) were constructed and not model_validated, we have to catch
189190
# warnings again when creating the cli
@@ -220,9 +221,18 @@ def main():
220221
else:
221222
raise Exception(f"Unknown command line type '{type(config).__name__}'")
222223
except Exception as e:
223-
import traceback
224-
traceback.print_exc()
225-
traceback.print_stack()
226-
#print(e)
224+
if config is None:
225+
print("There was a serious issue where the config file could not be created.\n"
226+
"The entire stack trace is provided below (please include it if filing a bug report).\n")
227+
traceback.print_exc()
228+
elif config.verbose:
229+
print("Verbose error logging is ENABLED.\n"
230+
"The entire stack trace has been provided below (please include it if filing a bug report):\n")
231+
traceback.print_exc()
232+
else:
233+
print("Verbose error logging is DISABLED.\n"
234+
"Please use the --verbose command line argument if you need more context for your error or file a bug report.")
235+
print(e)
236+
227237
sys.exit(1)
228238

contentctl/objects/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ class Config_Base(BaseModel):
154154

155155
path: DirectoryPath = Field(default=DirectoryPath("."), description="The root of your app.")
156156
app:CustomApp = Field(default_factory=CustomApp)
157+
verbose:bool = Field(default=False, description="Enable verbose error logging, including a stacktrace. "
158+
"This option makes debugging contentctl errors much easier, but produces way more "
159+
"output than is useful under most uses cases. "
160+
"Please use this flag if you are submitting a bug report or issue on GitHub.")
157161

158162
@field_serializer('path',when_used='always')
159163
def serialize_path(path: DirectoryPath)->str:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "contentctl"
3-
version = "4.0.5"
3+
version = "4.0.6"
44
description = "Splunk Content Control Tool"
55
authors = ["STRT <[email protected]>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)