Skip to content

Commit

Permalink
Move error over to logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-vessey committed Dec 2, 2024
1 parent 34d3e46 commit 0a0de6f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/StreamWrapper/Foxml.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Drupal\foxml\Utility\Fedora3\DatastreamLowLevelAdapterInterface;
use Drupal\foxml\Utility\Fedora3\ObjectLowLevelAdapterInterface;
use Psr\Log\LoggerInterface;

/**
* FOXML stream wrapper.
Expand Down Expand Up @@ -38,6 +39,13 @@ class Foxml extends ReadOnlyStream {
*/
protected FileSystem $fileSystem;

/**
* Logging channel.
*
* @var \Psr\Log\LoggerInterface
*/
protected LoggerInterface $logger;

/**
* Constructor.
*
Expand All @@ -50,6 +58,7 @@ public function __construct() {
$this->datastreamAdapter = \Drupal::service('foxml.parser.datastream_lowlevel_storage');
$this->objectAdapter = \Drupal::service('foxml.parser.object_lowlevel_storage');
$this->fileSystem = \Drupal::service('file_system');
$this->logger = \Drupal::service('logger.channel.foxml');
// phpcs:enable
}

Expand All @@ -76,7 +85,11 @@ protected function getLocalPath($uri = NULL) {
assert(is_string($path), 'Dereferenced path.');
}
catch (\Exception $e) {
trigger_error('Failed to dereference URI.', E_USER_WARNING);
$this->logger->warning('Failed to dereference URI "{uri}". Exception info: {message}, {trace}', [
'uri' => $uri,
'message' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
return FALSE;
}

Expand Down

0 comments on commit 0a0de6f

Please sign in to comment.