comparison Core/JobsEngine/JobStepResult.cpp @ 3240:e44e0127e553

Fix issue #134 (/patient/modify gives 500, should really be 400)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Feb 2019 17:26:45 +0100
parents 4e43e67f8ecf
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3239:407e1a188105 3240:e44e0127e553
44 result.timeout_ = timeout; 44 result.timeout_ = timeout;
45 return result; 45 return result;
46 } 46 }
47 47
48 48
49 JobStepResult JobStepResult::Failure(const ErrorCode& error) 49 JobStepResult JobStepResult::Failure(const ErrorCode& error,
50 const char* details)
50 { 51 {
51 JobStepResult result(JobStepCode_Failure); 52 JobStepResult result(JobStepCode_Failure);
52 result.error_ = error; 53 result.error_ = error;
54
55 if (details != NULL)
56 {
57 result.failureDetails_ = details;
58 }
59
53 return result; 60 return result;
54 } 61 }
55 62
63
64 JobStepResult JobStepResult::Failure(const OrthancException& exception)
65 {
66 return Failure(exception.GetErrorCode(),
67 exception.HasDetails() ? exception.GetDetails() : NULL);
68 }
69
56 70
57 unsigned int JobStepResult::GetRetryTimeout() const 71 unsigned int JobStepResult::GetRetryTimeout() const
58 { 72 {
59 if (code_ == JobStepCode_Retry) 73 if (code_ == JobStepCode_Retry)
60 { 74 {
76 else 90 else
77 { 91 {
78 throw OrthancException(ErrorCode_BadSequenceOfCalls); 92 throw OrthancException(ErrorCode_BadSequenceOfCalls);
79 } 93 }
80 } 94 }
95
96
97 const std::string& JobStepResult::GetFailureDetails() const
98 {
99 if (code_ == JobStepCode_Failure)
100 {
101 return failureDetails_;
102 }
103 else
104 {
105 throw OrthancException(ErrorCode_BadSequenceOfCalls);
106 }
107 }
81 } 108 }