Rescue ActiveRecord errors
With the previous logic, errors were not being surfaced correctly. When there is an ActiveRecord error (i.e bad params that don't meet validation), then the create action is rolled back and no record will exist (can't parse errors on a nil object). This will cause a 500 error. Rescueing the error means it can be surfaced through the resolver and handled appropriately by the client.
加载中
想要评论请 注册 或 登录