{"issue":{"created_at":"2011-12-03T21:52:02Z","state":"open","updated_at":"2011-12-03T21:52:02Z","comments":0,"user":{"gravatar_id":"e996de859f50f94a5d3ef754a0dee431","id":538696,"url":"https://api.github.com/users/raincole","avatar_url":"https://secure.gravatar.com/avatar/e996de859f50f94a5d3ef754a0dee431?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"raincole"},"body":"後端有三種回傳錯誤狀態的API，分別為：\r\n\r\n+ 未知錯誤、伺服器問題：無論40x或500，所有失敗的Ajax呼叫，請統一在`ajax:error`的callback中處理，只要顯示「發生未知錯誤」之類的通用敘述就行了。**所有**Ajax呼叫都必須處理此狀況。\r\n\r\n\r\n+ 一般錯誤：Ajax呼叫成功，但回傳的json為：\r\n\r\n```json\r\n{\r\n  \"status\" : \"ERROR\",\r\n  \"message\": \"a string\"\r\n}\r\n```\r\n    \r\n必須在`ajax:success`的callback中判斷`data['status'] == \"ERROR\"`以捕捉此狀況。和未知錯誤應共用同樣的UI。同樣地，**所有**Ajax呼叫都必須處理此狀況。\r\n\r\n+ 校驗失敗：Ajax呼叫成功，但回傳的json為：\r\n\r\n```json\r\n{\r\n  \"status\" : \"INVALID\",\r\n  \"message\": [\"an\", \"array\", \"of\", \"strings\"]\r\n}\r\n```\r\n必須在`ajax:success`的callback中判斷`data['status'] == \"INVALID\"`以捕捉此狀況。因為校驗訊息可能不只一條，所以和前兩種的顯示方式不一定相同，應該要分行輸出。**基本上**，只有`create`和`update`之類的Ajax呼叫才需要處理此狀況。","assignee":{"gravatar_id":"4b4bc333d8ee7c215476d7715667e8a1","id":839973,"url":"https://api.github.com/users/zetachang","avatar_url":"https://secure.gravatar.com/avatar/4b4bc333d8ee7c215476d7715667e8a1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"zetachang"},"number":27,"id":2439396,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"前端的error handlers","closed_at":null,"html_url":"https://github.com/zetachang/ntu_scheduler/issues/27","url":"https://api.github.com/repos/zetachang/ntu_scheduler/issues/27","milestone":null},"action":"opened"}