node-sdk
                                
                                
                                
                                    node-sdk copied to clipboard
                            
                            
                            
                        Improve error debuggability
if i make a mistake updating a Template that in fact does not exist, i only see:
HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (node_modules/got/dist/source/as-promise/index.js:118:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1671710227500,
    socket: 1671710227501,
    lookup: 1671710227501,
    connect: 1671710227537,
    secureConnect: 1671710227581,
    upload: 1671710227582,
    response: 1671710227789,
    end: 1671710227790,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 36,
      tls: 44,
      request: 1,
      firstByte: 207,
      download: 1,
      total: 290
    }
  },
  transloaditErrorCode: 'TEMPLATE_VALIDATION_ERROR'
}
I don’t know why it failed.
Yet if i code node_modules/transloadit/ to manually dump the body when this happens, I can see the API does reveal more about the nature of my fail:
{
  body: {
    error: 'TEMPLATE_VALIDATION_ERROR',
    message: "Invalid id/name: A Template with id/name 'xyz' doesn't exist for this app.",
    http_code: 400
  }
}
TLDR: would be cool to add body.message to the error that the consuming dev sees.