Yii Framework Forum: Exception thrown from core should with error code - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Exception thrown from core should with error code

#1 User is offline   kernel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 22-November 10

Posted 10 June 2012 - 09:46 PM

Not only message but also the code, to facilitate further determination.
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 10 June 2012 - 09:49 PM

I think using proper exceptions instead of old fashioned error handling is on the todo list for Yii 2.0.

At least I hope it is. :)
"Less noise - more signal"
3

#3 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 664
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 10 June 2012 - 10:20 PM

jacmoe, I'm thinking about creating more accounts to cast more votes on your post :)
Throwing exceptions is so much better than arbitrary return values or error states.
1

#4 User is offline   kernel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 22-November 10

Posted 11 June 2012 - 12:05 AM

I mean :

throw new Exception($message, $code);

The code is the $code in Exception.
0

#5 User is offline   Suralc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 10-January 12
  • Location:Germany

Posted 11 June 2012 - 07:45 AM

View Postkernel, on 11 June 2012 - 12:05 AM, said:

I mean :

throw new Exception($message, $code);

The code is the $code in Exception.


I'd prefer an exception hirachy like
InvalidUrlException(Invalid Url detected)->RequestException->HTTPException->Exception
in addition to the use of a exception code to handle these programaticly (hard to do this with messages)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users