0

i am using Zend Framework Zend_Acl i am wanting to throw an exception when the user is denied access to a resource. which exception class do i use?

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

2 Answers2

1

You could use

throw new Zend_Controller_Action_Exception('Forbidden', 403);
N D
  • 717
  • 6
  • 10
0

AFAIK you don't have a specific exception for that, if that's what you're asking. Create your own exception class which extends from Zend_Exception and throw that.

robertbasic
  • 4,325
  • 1
  • 27
  • 25
  • can i say that such exception classes are just for the purposes for readability in code, and does nothing too different from 1 another? – Jiew Meng Aug 03 '10 at 08:37
  • readability, plus based on the type of the exception or the exception code, you can do different things in the error controller (access denied, page not found, application error, etc...). – robertbasic Aug 03 '10 at 08:59
  • with `Zend_Exception`, i can also set the code right? `void __construct ([string $msg = ''], [int $code = 0], [ $previous = null]) `. the 2nd param? – Jiew Meng Aug 04 '10 at 10:43
  • and you can catch different types of exceptions, enabling your application to ignore issues that you expect to happen and deal with yourself. – ForrestLyman Jun 06 '13 at 03:13