user239237
user239237

Reputation: 662

Is it against proper MVC style to send error messages from the model?

Or should error messages be handled in the view? I usually try to just send true and false from my models.

Great to hear what you guys do!

Upvotes: 3

Views: 232

Answers (3)

tvanfosson
tvanfosson

Reputation: 532625

My models handle validation by throwing an exception when being persisted. The validation logic will collect a set of validation errors, including messages. If there are any validation errors, an exception is thrown. Views/controllers can interrogate the model to find the appropriate error messages if desired.

Upvotes: 2

Ritwik Bose
Ritwik Bose

Reputation: 6069

agreed. Model should be happy to throw up stuff as long as it is generated from information readily available to the model.

Upvotes: 3

mopoke
mopoke

Reputation: 10685

I would expect the model to throw an exception which can be handled by the view (and presented the the end user if appropriate).

Upvotes: 3

Related Questions