Skip to content

Commit

Permalink
Merge pull request #304 from oat-sa/feature/tr-1265/exception_grouping
Browse files Browse the repository at this point in the history
fix: simplifies exceptions management
  • Loading branch information
boajer authored Jan 14, 2022
2 parents e2b4132 + c9b71fe commit 0927bd2
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 8 deletions.
31 changes: 31 additions & 0 deletions src/qtism/common/QtiSdkPackageContentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* 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; under version 2
* of the License (non-upgradable).
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @license GPLv2
*/
declare(strict_types=1);

namespace qtism\common;

/**
* The QtiSdkPackageContentException intended to help unify the exception handlers behavior
*/
interface QtiSdkPackageContentException
{
}
3 changes: 2 additions & 1 deletion src/qtism/data/BranchRuleTargetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace qtism\data;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* An exception to be thrown when an error occurs while dealing with
* target of BranchingRules in AssessmentTest.
*/
class BranchRuleTargetException extends Exception
class BranchRuleTargetException extends Exception implements QtiSdkPackageContentException
{
/**
* The target is unknown.
Expand Down
3 changes: 2 additions & 1 deletion src/qtism/data/results/DuplicateSourceIdException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
namespace qtism\data\results;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* Class DuplicateSourceIdException
*/
class DuplicateSourceIdException extends Exception
class DuplicateSourceIdException extends Exception implements QtiSdkPackageContentException
{
}
3 changes: 2 additions & 1 deletion src/qtism/data/storage/StorageException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace qtism\data\storage;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* An error to be thrown when an error occurs while dealing with
* AssessmentTest description storage (loading/saving/parsing).
*/
class StorageException extends Exception
class StorageException extends Exception implements QtiSdkPackageContentException
{
/**
* The error is unknown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
namespace qtism\data\storage\php\marshalling;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* The exception class to use when exception occurs during PHP marshalling time.
*/
class PhpMarshallingException extends Exception
class PhpMarshallingException extends Exception implements QtiSdkPackageContentException
{
/**
* Error code to use when the error is unknown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
namespace qtism\data\storage\xml\marshalling;

use Exception;
use qtism\common\QtiSdkPackageContentException;
use qtism\data\QtiComponent;

/**
* Exception to be thrown when an error occurs during the marshalling process
* of a QtiComponent.
*/
class MarshallingException extends Exception
class MarshallingException extends Exception implements QtiSdkPackageContentException
{
/**
* A QtiComponent object that caused the exception to be thrown.
Expand Down
3 changes: 2 additions & 1 deletion src/qtism/runtime/pci/json/MarshallingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace qtism\runtime\pci\json;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* Exception to be thrown when a Marshalling error occurs while
* dealing with JSON Data.
*/
class MarshallingException extends Exception
class MarshallingException extends Exception implements QtiSdkPackageContentException
{
const UNKNOWN = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/qtism/runtime/rendering/RenderingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace qtism\runtime\rendering;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* Exception to be thrown when an error occurs during a Rendering
* process.
*/
class RenderingException extends Exception
class RenderingException extends Exception implements QtiSdkPackageContentException
{
/**
* Error code to use when the nature of the error
Expand Down
3 changes: 2 additions & 1 deletion src/qtism/runtime/storage/common/StorageException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace qtism\runtime\storage\common;

use Exception;
use qtism\common\QtiSdkPackageContentException;

/**
* The StorageException class represents exceptions that AssessmentTestSession
* Storage Services encounter an error.
*/
class StorageException extends Exception
class StorageException extends Exception implements QtiSdkPackageContentException
{
/**
* The error code to be used when the nature of the error is unknown.
Expand Down

0 comments on commit 0927bd2

Please sign in to comment.