Add-on: clearer error message when job compiler refuses the job
Blender now shows the actual returned error from the Manager when job submission fails, rather than a generic "failed" message.
This commit is contained in:
parent
6f876658c1
commit
fa69cc102b
@ -18,11 +18,19 @@ if TYPE_CHECKING:
|
|||||||
PackThread as _PackThread,
|
PackThread as _PackThread,
|
||||||
Message as _Message,
|
Message as _Message,
|
||||||
)
|
)
|
||||||
from .manager.models import SubmittedJob as _SubmittedJob
|
from .manager.models import (
|
||||||
|
Error as _Error,
|
||||||
|
SubmittedJob as _SubmittedJob,
|
||||||
|
)
|
||||||
|
from .manager.api_client import ApiClient as _ApiClient
|
||||||
|
from .manager.exceptions import ApiException as _ApiException
|
||||||
else:
|
else:
|
||||||
_PackThread = object
|
_PackThread = object
|
||||||
_Message = object
|
_Message = object
|
||||||
_SubmittedJob = object
|
_SubmittedJob = object
|
||||||
|
_ApiClient = object
|
||||||
|
_ApiException = object
|
||||||
|
_Error = object
|
||||||
|
|
||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -440,6 +448,10 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
"Cached job type is old. Refresh the job types and submit again, please",
|
"Cached job type is old. Refresh the job types and submit again, please",
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
if ex.status == 400:
|
||||||
|
error = parse_api_error(api_client, ex)
|
||||||
|
self.report({"ERROR"}, error.message)
|
||||||
|
return
|
||||||
self.report({"ERROR"}, f"Could not submit job: {ex.reason}")
|
self.report({"ERROR"}, f"Could not submit job: {ex.reason}")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -518,3 +530,18 @@ classes = (
|
|||||||
FLAMENCO3_OT_explore_file_path,
|
FLAMENCO3_OT_explore_file_path,
|
||||||
)
|
)
|
||||||
register, unregister = bpy.utils.register_classes_factory(classes)
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_api_error(api_client: _ApiClient, ex: _ApiException) -> _Error:
|
||||||
|
"""Parse the body of an ApiException into an manager.models.Error instance."""
|
||||||
|
|
||||||
|
from .manager.models import Error
|
||||||
|
|
||||||
|
class MockResponse:
|
||||||
|
data: str
|
||||||
|
|
||||||
|
response = MockResponse()
|
||||||
|
response.data = ex.body
|
||||||
|
|
||||||
|
error: _Error = api_client.deserialize(response, (Error, ), True)
|
||||||
|
return error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user