Skip to content

Commit 0b61cb4

Browse files
committed
Use own Exception
1 parent 07ee5cc commit 0b61cb4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/CorsService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Fruitcake\Cors;
1414

15+
use Fruitcake\Cors\Exceptions\InvalidOptionException;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
1718

@@ -55,12 +56,12 @@ private function normalizeOptions(array $options = []): array
5556
];
5657

5758
if ($options['exposedHeaders'] && !is_array($options['exposedHeaders'])) {
58-
throw new \RuntimeException("CORS option `exposedHeaders` should be `false` or an array");
59+
throw new InvalidOptionException("CORS option `exposedHeaders` should be `false` or an array");
5960
}
6061

6162
foreach (['allowedOrigins', 'allowedOriginsPatterns', 'allowedHeaders', 'allowedMethods'] as $key) {
6263
if (!is_array($options[$key])) {
63-
throw new \RuntimeException("CORS option `{$key}` should be an array");
64+
throw new InvalidOptionException("CORS option `{$key}` should be an array");
6465
}
6566
}
6667

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* This file is part of fruitcake/php-cors
5+
*
6+
* (c) Barryvdh <barryvdh@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fruitcake\Cors\Exceptions;
13+
14+
15+
class InvalidOptionException extends \RuntimeException
16+
{
17+
}

0 commit comments

Comments
 (0)