aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/ShaarliMiddleware.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/front/ShaarliMiddleware.php')
-rw-r--r--application/front/ShaarliMiddleware.php26
1 files changed, 1 insertions, 25 deletions
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php
index a2a3837b..c015c0c6 100644
--- a/application/front/ShaarliMiddleware.php
+++ b/application/front/ShaarliMiddleware.php
@@ -3,7 +3,6 @@
3namespace Shaarli\Front; 3namespace Shaarli\Front;
4 4
5use Shaarli\Container\ShaarliContainer; 5use Shaarli\Container\ShaarliContainer;
6use Shaarli\Front\Exception\ShaarliFrontException;
7use Shaarli\Front\Exception\UnauthorizedException; 6use Shaarli\Front\Exception\UnauthorizedException;
8use Slim\Http\Request; 7use Slim\Http\Request;
9use Slim\Http\Response; 8use Slim\Http\Response;
@@ -53,35 +52,12 @@ class ShaarliMiddleware
53 $this->checkOpenShaarli($request, $response, $next); 52 $this->checkOpenShaarli($request, $response, $next);
54 53
55 return $next($request, $response); 54 return $next($request, $response);
56 } catch (ShaarliFrontException $e) {
57 // Possible functional error
58 $this->container->pageBuilder->reset();
59 $this->container->pageBuilder->assign('message', nl2br($e->getMessage()));
60
61 $response = $response->withStatus($e->getCode());
62
63 return $response->write($this->container->pageBuilder->render('error', $this->container->basePath));
64 } catch (UnauthorizedException $e) { 55 } catch (UnauthorizedException $e) {
65 $returnUrl = urlencode($this->container->environment['REQUEST_URI']); 56 $returnUrl = urlencode($this->container->environment['REQUEST_URI']);
66 57
67 return $response->withRedirect($this->container->basePath . '/login?returnurl=' . $returnUrl); 58 return $response->withRedirect($this->container->basePath . '/login?returnurl=' . $returnUrl);
68 } catch (\Throwable $e) {
69 // Unknown error encountered
70 $this->container->pageBuilder->reset();
71 if ($this->container->conf->get('dev.debug', false)) {
72 $this->container->pageBuilder->assign('message', $e->getMessage());
73 $this->container->pageBuilder->assign(
74 'stacktrace',
75 nl2br(get_class($e) .': '. PHP_EOL . $e->getTraceAsString())
76 );
77 } else {
78 $this->container->pageBuilder->assign('message', t('An unexpected error occurred.'));
79 }
80
81 $response = $response->withStatus(500);
82
83 return $response->write($this->container->pageBuilder->render('error', $this->container->basePath));
84 } 59 }
60 // Other exceptions are handled by ErrorController
85 } 61 }
86 62
87 /** 63 /**