exceptions-shortcuts.js 365 B

123456789101112131415161718192021
  1. import Ember from 'ember';
  2. export default Ember.Mixin.create({
  3. // Shorthands for raising errors
  4. throw403: function(reason) {
  5. if (reason) {
  6. throw {
  7. status: 403,
  8. responseJSON: {
  9. detail: reason
  10. }
  11. };
  12. } else {
  13. throw { status: 403 };
  14. }
  15. },
  16. throw404: function() {
  17. throw { status: 404 };
  18. }
  19. });