discourse/discourse — pull request #464 by ZogStriP (2013-03-14 20:59:43+00:00)
Title: displays a message when a failure happen while creating a new category

Meta: [Failed to create new category when set the default_locale to zh_CN](http://meta.discourse.org/t/failed-to-create-new-category-when-set-the-default-locale-to-zh-cn/4703/4)

This PR changes the `create_category_definition` after_create callback to use the `!` version of the `create_topic` method that will make Rails throw an exception which allows the application to respond with a `422` code instead of the `500` code.

Unfortunately, I did not manage to get Rails to pass the error messages coming from the callback. Instead, I added a test in the `edit_category_view` in the `error` callback to add a generic error message whenever the server respond with a `422` code but without any error message.

I've also added some length validation (both client & server side) to the `name` property of the `category` so that it generates better error messages.