netglue / Expressive-Prismic

Zend Expressive library for working with prismic.io's content management api
MIT License
1 stars 0 forks source link

Show exception message for debugging #3

Closed Mondane closed 6 years ago

Mondane commented 6 years ago

I'm trying to implement this package and got this error:

An Unexpected Error Occurred

Might be a good idea to, at least in development mode, show the Exception in https://github.com/netglue/Expressive-Prismic/blob/master/src/Middleware/ErrorResponseGenerator.php#L46

gsteel commented 6 years ago

If you look at the config provider dependency aliases https://github.com/netglue/Expressive-Prismic/blob/master/src/ConfigProvider.php#L124 - Out of the box, the library replaces the default 404 and 500 error handlers - I use the "development mode" of Expressive to override this alias with something like

       'factories'  => [
            'WhoopsError'                       => Container\WhoopsErrorResponseGeneratorFactory::class,
            'Zend\Expressive\Whoops'            => Container\WhoopsFactory::class,
            'Zend\Expressive\WhoopsPageHandler' => Container\WhoopsPageHandlerFactory::class,
        ],
        'aliases' => [
            ErrorResponseGenerator::class       => 'WhoopsError',
        ],

This way, I get detailed exception traces in Whoops by enabling development mode with composer development-enable. I'm not likely to add any exception information in the shipped ErrorResponseGenerator because it could potentially leak your private access token to Prismic in production.