Skip to content

Commit bf9382e

Browse files
author
Alexander Kotynia
committed
[Form] Make exception handling consistent with other components
1 parent d6376c1 commit bf9382e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+178
-212
lines changed

src/Symfony/Component/Form/AbstractExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\Component\Form\Exception\Exception;
14+
use Symfony\Component\Form\Exception\InvalidArgumentException;
1515
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1616

1717
/**
@@ -53,7 +53,7 @@ public function getType($name)
5353
}
5454

5555
if (!isset($this->types[$name])) {
56-
throw new Exception(sprintf('The type "%s" can not be loaded by this extension', $name));
56+
throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension', $name));
5757
}
5858

5959
return $this->types[$name];

src/Symfony/Component/Form/Button.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function offsetExists($offset)
6565
*
6666
* @param mixed $offset
6767
*
68-
* @throws \BadMethodCallException
68+
* @throws BadMethodCallException
6969
*/
7070
public function offsetGet($offset)
7171
{
72-
throw new \BadMethodCallException('Buttons cannot have children.');
72+
throw new BadMethodCallException('Buttons cannot have children.');
7373
}
7474

7575
/**
@@ -80,11 +80,11 @@ public function offsetGet($offset)
8080
* @param mixed $offset
8181
* @param mixed $value
8282
*
83-
* @throws \BadMethodCallException
83+
* @throws BadMethodCallException
8484
*/
8585
public function offsetSet($offset, $value)
8686
{
87-
throw new \BadMethodCallException('Buttons cannot have children.');
87+
throw new BadMethodCallException('Buttons cannot have children.');
8888
}
8989

9090
/**
@@ -94,11 +94,11 @@ public function offsetSet($offset, $value)
9494
*
9595
* @param mixed $offset
9696
*
97-
* @throws \BadMethodCallException
97+
* @throws BadMethodCallException
9898
*/
9999
public function offsetUnset($offset)
100100
{
101-
throw new \BadMethodCallException('Buttons cannot have children.');
101+
throw new BadMethodCallException('Buttons cannot have children.');
102102
}
103103

104104
/**
@@ -126,11 +126,11 @@ public function getParent()
126126
* @param null $type
127127
* @param array $options
128128
*
129-
* @throws \BadMethodCallException
129+
* @throws BadMethodCallException
130130
*/
131131
public function add($child, $type = null, array $options = array())
132132
{
133-
throw new \BadMethodCallException('Buttons cannot have children.');
133+
throw new BadMethodCallException('Buttons cannot have children.');
134134
}
135135

136136
/**
@@ -140,11 +140,11 @@ public function add($child, $type = null, array $options = array())
140140
*
141141
* @param string $name
142142
*
143-
* @throws \BadMethodCallException
143+
* @throws BadMethodCallException
144144
*/
145145
public function get($name)
146146
{
147-
throw new \BadMethodCallException('Buttons cannot have children.');
147+
throw new BadMethodCallException('Buttons cannot have children.');
148148
}
149149

150150
/**
@@ -166,11 +166,11 @@ public function has($name)
166166
*
167167
* @param string $name
168168
*
169-
* @throws \BadMethodCallException
169+
* @throws BadMethodCallException
170170
*/
171171
public function remove($name)
172172
{
173-
throw new \BadMethodCallException('Buttons cannot have children.');
173+
throw new BadMethodCallException('Buttons cannot have children.');
174174
}
175175

176176
/**
@@ -196,11 +196,11 @@ public function getErrors()
196196
*
197197
* @param string $modelData
198198
*
199-
* @throws \BadMethodCallException
199+
* @throws BadMethodCallException
200200
*/
201201
public function setData($modelData)
202202
{
203-
throw new \BadMethodCallException('Buttons cannot have data.');
203+
throw new BadMethodCallException('Buttons cannot have data.');
204204
}
205205

206206
/**
@@ -288,11 +288,11 @@ public function getPropertyPath()
288288
*
289289
* @param FormError $error
290290
*
291-
* @throws \BadMethodCallException
291+
* @throws BadMethodCallException
292292
*/
293293
public function addError(FormError $error)
294294
{
295-
throw new \BadMethodCallException('Buttons cannot have errors.');
295+
throw new BadMethodCallException('Buttons cannot have errors.');
296296
}
297297

298298
/**

0 commit comments

Comments
 (0)