From 992ce8a37c5797419255da5bfca16aa8aef3b043 Mon Sep 17 00:00:00 2001 From: coderkun Date: Fri, 4 Apr 2014 14:00:01 +0200 Subject: [PATCH] add type to WrongFiletypeException --- app/exceptions/WrongFiletypeException.inc | 30 +++++++++++++++++-- .../submit/SubmitQuesttypeController.inc | 2 +- questtypes/submit/html/quest.tpl | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/exceptions/WrongFiletypeException.inc b/app/exceptions/WrongFiletypeException.inc index a3bfbe41..131356b8 100644 --- a/app/exceptions/WrongFiletypeException.inc +++ b/app/exceptions/WrongFiletypeException.inc @@ -30,7 +30,14 @@ * * @var string */ - const MESSAGE = 'File has wrong type'; + const MESSAGE = 'File has wrong type ā€œ%sā€'; + + /** + * Type of file + * + * @var string + */ + private $type; @@ -38,12 +45,29 @@ /** * Construct a new exception. */ - function __construct($message=self::MESSAGE, $code=self::CODE) + function __construct($type, $message=self::MESSAGE, $code=self::CODE) { parent::__construct( $message, - $code + $code, + $type ); + + // Store values + $this->type = $type; + } + + + + + /** + * Get type of file. + * + * @return Type of file + */ + public function getType() + { + return $this->type; } } diff --git a/questtypes/submit/SubmitQuesttypeController.inc b/questtypes/submit/SubmitQuesttypeController.inc index eecafb3b..18e55d1b 100644 --- a/questtypes/submit/SubmitQuesttypeController.inc +++ b/questtypes/submit/SubmitQuesttypeController.inc @@ -67,7 +67,7 @@ } if(is_null($answerMimetype)) { throw new \hhu\z\exceptions\SubmissionNotValidException( - new \hhu\z\exceptions\WrongFiletypeException() + new \hhu\z\exceptions\WrongFiletypeException($answer['type']) ); } diff --git a/questtypes/submit/html/quest.tpl b/questtypes/submit/html/quest.tpl index 47b45bd4..06dc273d 100644 --- a/questtypes/submit/html/quest.tpl +++ b/questtypes/submit/html/quest.tpl @@ -1,7 +1,7 @@

getNestedException() instanceof \hhu\z\exceptions\WrongFiletypeException) : ?> - + getNestedException()->getType())?> getNestedException() instanceof \hhu\z\exceptions\WrongFiletypeException) : ?> getNestedException() instanceof \hhu\z\exceptions\FileUploadException) : ?>