How properly perform passing operation result to View

Posted by atomAltera on Programmers See other posts from Programmers or by atomAltera
Published on 2012-11-30T14:01:17Z Indexed on 2012/11/30 17:19 UTC
Read the original article Hit count: 482

Filed under:
|

I'm developing web site on self made MVC engine. I have actionController that handles operations like register, login, post submit and etc. actionController receives operation name and parameters. Of course it mast handle errors such user with same nick already exists or password is to short about which action handler have to notify user. The question is which is the best way to organize errors, such that View could easily get localized user notification message.

I see two ways

First one: define error constants like

ERR_NICK_BUSY = '1'
ERR_NICK_INVALID = '2'
...

and localization map

local[ERR_NICK_BUSY] = 'User with the same nick already registered'
local[ERR_NICK_INVALID ] = 'Nick, you entered is invalid'
...

And second one: define abstract constants like

ERR_FIELD_BUSY = '1'
ERR_FIELD_INVALID = '2'
...

and pass them with field name. In this case localization looks like

local['nick_'+ERR_FIELD_BUSY] = 'User with the same nick already registered'
...

I don't like both this methods. Can you advise something else?

© Programmers or respective owner

Related posts about coding-style

Related posts about mvc