-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Greg Roach
committed
Jun 2, 2018
1 parent
28dbc60
commit 907b27b
Showing
17 changed files
with
575 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Exception thrown when a family cannot be accessed due to privacy rules. | ||
*/ | ||
class FamilyAccessDeniedException extends AccessDeniedHttpException { | ||
/** | ||
* FamilyNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This family does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Exception thrown when a family does not exist. | ||
*/ | ||
class FamilyNotFoundException extends NotFoundHttpException { | ||
/** | ||
* FamilyNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This family does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Exception; | ||
use Fisharebest\Webtrees\Http\Controllers\ErrorController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\HttpException; | ||
use Whoops\Handler\PrettyPageHandler; | ||
use Whoops\Run; | ||
|
||
/** | ||
* Convert an exception into an HTTP response | ||
*/ | ||
class Handler { | ||
/** | ||
* Render an exception into an HTTP response. | ||
* | ||
* @param Request $request | ||
* @param Exception $exception | ||
* | ||
* @return Response | ||
*/ | ||
public function render(Request $request, Exception $exception): Response { | ||
if ($exception instanceof HttpException) { | ||
// Show a friendly page for expected exceptions. | ||
if ($request->isXmlHttpRequest()) { | ||
$response = new Response($exception->getMessage(), $exception->getStatusCode()); | ||
} else { | ||
$controller = new ErrorController; | ||
$response = $controller->errorResponse($exception); | ||
} | ||
} else { | ||
// Show an error page for unexpected exceptions. | ||
if (getenv('DEBUG')) { | ||
// Local dev environment? Show full debug. | ||
$whoops = new Run; | ||
$whoops->pushHandler(new PrettyPageHandler); | ||
$whoops->handleException($exception); | ||
} else { | ||
// Running remotely? Show a friendly error page. | ||
$controller = new ErrorController; | ||
$response = $controller->unhandledExceptionResponse($request, $exception); | ||
} | ||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Exception thrown when an individual cannot be accessed due to privacy rules. | ||
*/ | ||
class IndividualAccessDeniedException extends AccessDeniedHttpException { | ||
/** | ||
* IndividualNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This individual does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Exception thrown when an individual does not exist. | ||
*/ | ||
class IndividualNotFoundException extends NotFoundHttpException { | ||
/** | ||
* IndividualNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This individual does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Exception thrown when a media cannot be accessed due to privacy rules. | ||
*/ | ||
class MediaAccessDeniedException extends AccessDeniedHttpException { | ||
/** | ||
* MediaNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This media object does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Exception thrown when a media does not exist. | ||
*/ | ||
class MediaNotFoundException extends NotFoundHttpException { | ||
/** | ||
* MediaNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This media object does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Exception thrown when a note cannot be accessed due to privacy rules. | ||
*/ | ||
class NoteAccessDeniedException extends AccessDeniedHttpException { | ||
/** | ||
* NoteNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This note does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Exception thrown when a note does not exist. | ||
*/ | ||
class NoteNotFoundException extends NotFoundHttpException { | ||
/** | ||
* NoteNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This note does not exist or you do not have permission to view it.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* webtrees: online genealogy | ||
* Copyright (C) 2018 webtrees development team | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Fisharebest\Webtrees\Exceptions; | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Exception thrown when a record cannot be accessed due to privacy rules. | ||
*/ | ||
class RecordAccessDeniedException extends AccessDeniedHttpException { | ||
/** | ||
* RecordNotFoundException constructor. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(I18N::translate('This record does not exist or you do not have permission to view it.')); | ||
} | ||
} |
Oops, something went wrong.