Problem/Motivation

When a GuzzleException is caught when fetching a remote file, it is discarded, and instead the code relies on dropping through to a very generic error message stating that SFP encountered an error. This is a shame, because the Guzzle exception is likely to contain some amount of information about the reason the fetch failed.

Steps to reproduce

1. Configure a base URL for a non-existent site
2. Visit a page containing a missing image (you could remove the image from the local file system if it does exist locally.
3. Go to the watchdog log. Notice that the error message recorded says "Stage File Proxy encountered an unknown error by retrieving file ...". It does not actually mention anything about it not being able to find the site.

Proposed resolution

Log information about the exception in the catch clause using watchdog_exception().

Remaining tasks

  • Create a patch
  • Review

User interface changes

Error messages will be more verbose.

API changes

None.

Data model changes

None.

Release notes snippet

When encountering errors while downloading remote files, error messages in the log will now display more information about the actual problem encountered.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eelkeblok created an issue. See original summary.

eelkeblok’s picture

Issue summary: View changes
eelkeblok’s picture

Here's a patch. It doesn't include tests (there don't seem to be any tests testing the error handling), I'm not sure if they are desired. One small nag with testing this is that the watchdog_exception function completely bypasses OO/CI logging with a logger channel, which is a downright shame, so testing it would be a bit more involved that just inspecting the logger.

eelkeblok’s picture

Assigned: eelkeblok » Unassigned
Status: Active » Needs review
eelkeblok’s picture

Issue summary: View changes
tobiberlin’s picture

+1 for this! I do not understand why the catch block is not used - I needed to set a breakpoint and used XDebug to find out what exactly was the problem

eelkeblok’s picture

Issue summary: View changes
RichardGaunt’s picture

This is fantastic, I have included this patch in my build and works as intended providing much better logging of stage file proxy exceptions.

eelkeblok’s picture

Should we consider this RTBC then..? The code is not very exciting.

greggles’s picture

watchdog_exception is deprecated, right?

That could be fixed - https://www.drupal.org/node/2932520

eelkeblok’s picture

Don't think it is, that CR is draft. Good idea, though. Didn't know that is the official "solution". Probably just as well, always had to look in the code how to format the message :)

greggles’s picture

Great point, I just assumed all procedural code was gone. So it's not deprecated yet, but should be and hopefully will be soon :)

I'd be happy to commit this with that fix.

eelkeblok’s picture

You'd think so :) I always have a brief inner battle when an opportunity for watchdog_exception() comes along. So I'm actually glad with this guidance.

Have an MR :)

emek’s picture

I have tried the patch from #13 and it works and gives me a better error message.

ivnish’s picture

Status: Needs review » Reviewed & tested by the community

It works, thanks

  • greggles committed 32eca79 on 8.x-1.x authored by eelkeblok
    Issue #3161884: Improve usefulness of error message when SFP encounters...
greggles’s picture

Status: Reviewed & tested by the community » Fixed

This is now merged/fixed. Thanks for the improvement and the reviews.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.