abort()
次のようなメソッドを使用して、flask-restful のエラー メッセージをクライアントに簡単に伝達できます。
abort(500, message="Fatal error: Pizza the Hutt was found dead earlier today
in the back seat of his stretched limo. Evidently, the notorious gangster
became locked in his car and ate himself to death.")
これにより、次のjson出力が生成されます
{
"message": "Fatal error: Pizza the Hutt was found dead earlier today
in the back seat of his stretched limo. Evidently, the notorious gangster
became locked in his car and ate himself to death.",
"status": 500
}
追加のメンバーを使用して json 出力をカスタマイズする方法はありますか? 例えば:
{
"sub_code": 42,
"action": "redirect:#/Outer/Space"
"message": "You idiots! These are not them! You've captured their stunt doubles!",
"status": 500
}