HackGT / registration

Powerful and extensible registration system for hackathons and other large events
https://registration.hack.gt
MIT License
6 stars 1 forks source link

Add better error message for missing email content #202

Open bunsenmcdubbs opened 6 years ago

bunsenmcdubbs commented 6 years ago

Empty emails for application/confirmation lead to errors when the email code is triggered. This error should be more descriptive for admins/developers.

Current error (stacktrace):

{ Error: Bad Request
    at Request.http [as _callback] (node_modules/@sendgrid/client/src/classes/client.js:124:25)
    at Request.self.callback (node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
  code: 400,
  message: 'Bad Request',
  response:
   { headers:
      { server: 'nginx',
        date: 'Sat, 03 Mar 2018 22:34:45 GMT',
        'content-type': 'application/json',
        'content-length': '426',
        connection: 'close',
        'access-control-allow-origin': 'https://sendgrid.api-docs.io',
        'access-control-allow-methods': 'POST',
        'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
        'access-control-max-age': '600',
        'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html' },
     body: { errors: [Array] } } }
evan10s commented 5 years ago

This error happens when a participant submits an application, but we can't tell them the error since there's no way for them to fix it. But to let admins know to fix it when registration is first started, we can log a warning to the console when the application is first started and show a prominent message in the UI to all admin users.