nanogiants/nestjs-swagger-api-exception-decorator

Custom placeholders

jsproede opened this issue · 0 comments

Something like this:

export const TemplatedApiException = buildTemplatedApiExceptionDecorator(
  {
    statusCode: '$status',
    clientCode: '$clientCode',
    message: '$description',
    errors: [
      {
        string: 'string',
      },
    ],
    path: 'string',
    timestamp: '1970-01-01T15:30:11',
  },
  {
    requiredProperties: ['statusCode', 'message', 'timestamp'],
    placeholders: {
       'clientCode': (e) => { (e as BaseException).getClientCode(); }
    }
  },
);

(I'm sorry for my poor typescript)

Originally posted by @lzkill in #17 (comment)