Skip to content

Commit

Permalink
Some tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Nov 10, 2024
1 parent 5dd888f commit 22f3e71
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/posting/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,23 +696,21 @@ def build_request_model(self, request_options: Options) -> RequestModel:
def on_curl_message(self, event: CurlMessage):
try:
curl_import = CurlImport(event.curl_command)
except SystemExit:
request_model = curl_import.to_request_model()
except Exception as e:
self.notify(
title="Could not parse curl request",
message="An error occurred while parsing the curl request.",
message=f"An error occurred: {e}",
timeout=5,
severity="error",
)
return

request_model = curl_import.to_request_model()
self.load_request_model(request_model)

self.notify(
title="Curl request imported",
message=f"Successfully imported curl request to {curl_import.url}",
timeout=3,
)
else:
self.load_request_model(request_model)
self.notify(
title="Curl request imported",
message=f"Successfully imported curl request to {curl_import.url}",
timeout=3,
)

def load_request_model(self, request_model: RequestModel) -> None:
"""Load a request model into the UI."""
Expand Down

0 comments on commit 22f3e71

Please sign in to comment.