Skip to content
Permalink
Browse files

Created an exception to error 405 (Method Not Allowed) and changed th…

…e delete action in bake to use it.
  • Loading branch information...
jrbasso committed Oct 31, 2010
1 parent 4eed660 commit e380b76e16a9fdc62b03740e5abeb7d1309dcd3e
Showing with 21 additions and 1 deletion.
  1. +1 −1 cake/console/templates/default/actions/controller_actions.ctp
  2. +20 −0 cake/libs/exceptions.php
@@ -116,7 +116,7 @@

public function <?php echo $admin; ?>delete($id = null) {
if (!$this->request->is('post')) {
throw new ForbiddenException();
throw new MethodNotAllowedException();
}
if (!$id) {
<?php if ($wannaUseSession): ?>
@@ -99,6 +99,26 @@ public function __construct($message = null, $code = 404) {
}
}
/**
* Represents an HTTP 405 error.
*
* @package cake.libs
*/
class MethodNotAllowedException extends RuntimeException {
/**
* Constructor
*
* @param string $message If no message is given 'Method Not Allowed' will be the message
* @param string $code Status code, defaults to 401
*/
public function __construct($message = null, $code = 405) {
if (empty($message)) {
$message = 'Method Not Allowed';
}
parent::__construct($message, $code);
}
}
/**
* Represents an HTTP 500 error.
*

0 comments on commit e380b76

Please sign in to comment.
You can’t perform that action at this time.