ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclInputException.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Services/Exceptions/classes/class.ilException.php';
5 
18 
19  const TYPE_EXCEPTION = 0;
20  const LENGTH_EXCEPTION = 1;
21  const REGEX_EXCEPTION = 2;
22  const UNIQUE_EXCEPTION = 3;
23  const NOT_URL = 4;
24  const NOT_IMAGE = 5;
25  const WRONG_FILE_TYPE = 6;
26  const CUSTOM_MESSAGE = 7;
28 
29 
33  protected $exception_type;
34 
38  protected $additional_text;
39 
40 
44  public function __construct($exception_type, $additional_text = "") {
45  parent::__construct($exception_type);
46  $this->exception_type = $exception_type;
47  $this->additional_text = $additional_text;
48  }
49 
50 
54  public function getExceptionType() {
55  return $this->exception_type;
56  }
57 
58 
62  public function __toString() {
63  global $DIC;
64  $lng = $DIC['lng'];
65 
66  switch ($this->exception_type) {
67  case self::TYPE_EXCEPTION:
68  $message = $lng->txt('dcl_wrong_input_type');
69  break;
70  case self::LENGTH_EXCEPTION:
71  $message = $lng->txt('dcl_wrong_length');
72  break;
73  case self::REGEX_EXCEPTION:
74  $message = $lng->txt('dcl_wrong_regex');
75  break;
76  case self::REGEX_CONFIG_EXCEPTION:
77  $message = $lng->txt('dcl_invalid_regex_config');
78  break;
79  case self::UNIQUE_EXCEPTION:
80  $message = $lng->txt('dcl_unique_exception');
81  break;
82  case self::NOT_URL:
83  $message = $lng->txt('dcl_noturl_exception');
84  break;
85  case self::NOT_IMAGE:
86  $message = $lng->txt('dcl_notimage_exception');
87  break;
88  case self::WRONG_FILE_TYPE:
89  $message = $lng->txt('dcl_not_supported_file_type');
90  break;
91  case self::CUSTOM_MESSAGE:
93  break;
94  default:
95  $message = $lng->txt('dcl_unknown_exception');
96  }
97 
98  if(strlen($this->additional_text) > 0) {
99  $message .= " ".$this->additional_text;
100  }
101 
102  return $message;
103  }
104 }
Base class for ILIAS Exception handling.
Class ilDclBaseFieldModel.
__construct($exception_type, $additional_text="")
global $lng
Definition: privfeed.php:17
global $DIC