mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Add simple test for extracting error title
CURA-7959
This commit is contained in:
parent
32ec72a28c
commit
cf8113608f
3 changed files with 39 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import json
|
||||
import threading
|
||||
from json import JSONDecodeError
|
||||
from typing import List, Dict, Any, Callable, Union, Optional
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
|
@ -271,7 +272,11 @@ class DFFileExportAndUploadManager:
|
|||
def extractErrorTitle(reply_body: Optional[str]) -> str:
|
||||
error_title = ""
|
||||
if reply_body:
|
||||
reply_dict = json.loads(reply_body)
|
||||
try:
|
||||
reply_dict = json.loads(reply_body)
|
||||
except JSONDecodeError:
|
||||
Logger.logException("w", "Unable to extract title from reply body")
|
||||
return error_title
|
||||
if "errors" in reply_dict and len(reply_dict["errors"]) >= 1 and "title" in reply_dict["errors"][0]:
|
||||
error_title = reply_dict["errors"][0]["title"]
|
||||
return error_title
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue