Skip to content

Commit

Permalink
more verbosity in case of import dicom error in orthanc
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Jun 10, 2023
1 parent 0094209 commit 993ac81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions GaelO2/app/GaelO/Adapters/HttpClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
use App\GaelO\Interfaces\Adapters\HttpClientInterface;
use App\GaelO\Interfaces\Adapters\Psr7ResponseInterface;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Pool;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Log;

class HttpClientAdapter implements HttpClientInterface
{
Expand Down Expand Up @@ -67,8 +69,15 @@ public function requestUploadArrayDicom(string $method, string $uri, array $file
'fulfilled' => function (Response $response, $index) use (&$responseArray) {
$responseArray[] = new Psr7ResponseAdapter($response);
},
'rejected' => function ($reason, $index) {
'rejected' => function (RequestException $exception, $index) {
$reason = "Error sending dicom to orthanc";
if ($exception->hasResponse()) {
$reason = $exception->getResponse()->getReasonPhrase();
} else {
$reason = $exception->getMessage();
}
// this is delivered each failed request
Log::error('DICOM Import Failed in Orthanc Temporary ' + $reason);
},
]);

Expand Down Expand Up @@ -147,7 +156,7 @@ public function rowRequest(string $method, string $uri, $body, ?array $headers,
$options['sink'] = $ressourceDestination;
}

if(!$httpErrors){
if (!$httpErrors) {
$options['http_errors'] = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function execute(ValidateDicomUploadRequest $validateDicomUploadRequest,

if ($expectedNumberOfInstances !== $importedNumberOfInstances) {
$this->orthancService->deleteFromOrthanc("studies", $importedOrthancStudyID);
throw new GaelOValidateDicomException("Imported DICOM not matching announced number of Instances");
throw new GaelOValidateDicomException("Imported DICOM (".$importedNumberOfInstances.") not matching announced number of Instances (".$expectedNumberOfInstances.")");
}

//Anonymize and store new anonymized study Orthanc ID
Expand Down

0 comments on commit 993ac81

Please sign in to comment.