Explorer: Exception Messages Printed in Results
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3576615. -->
Reported by: [robloach](https://www.drupal.org/user/61114)
Related to !18
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>There are exceptions which messages are printed directly into the user interface. This can include sensitive data or file paths that sometimes we shouldn't expose to the user.</p>
<pre>$form_state->set('result', [<br> 'error' => $this->t('Error: @message', ['@message' => $e->getMessage()]),<br>]);<br>$this->messenger()->addError($this->t('Failed to load document: @message', ['@message' => $e->getMessage()]));</pre><h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Come up with a set of Exceptions that the DocumentLoader can run into, throw those Exceptions, and have the Exception details logged instead of displayed to the end user.</p>
<p>Something like....</p>
<pre>$form_state->set('result', [<br> 'error' => $this->t('An error occurred while loading the document. See <a href=":url">the logs</a> for details.', [<br> ':url' => '/admin/reports/dblog',<br> ]),<br>]);<br>$this->getLogger('document_loader')->error(<br> 'Document Loader error: @message',<br> ['@message' => $e->getMessage(), 'exception' => $e],<br>);</pre><h3 id="summary-ui-changes">User interface changes</h3>
<p>Rather than reading the exception directly, users are then asked to visit the logs, so that only site administrators can see it, and not just the users.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>Perhaps some new Exceptions introduced for the Document Loader.</p>
> Related issue: [Issue #3576934](https://www.drupal.org/node/3576934)
> Related issue: [Issue #3575269](https://www.drupal.org/node/3575269)
issue