Conversation
| (content) => { | ||
| return fileWriter(content, path.join(dirPath, 'resource.ts')) | ||
| .then(() => fileWriter('', path.join(dirPath, 'handler.ts'))) | ||
| .catch(console.error); |
There was a problem hiding this comment.
This was in the wrong place. It was intended to catch codegen errors but this is while writing code to the files.
| expect(e).toBeInstanceOf(Error); | ||
| expect(printSpy).toBeCalledTimes(2); | ||
| expect(printSpy).toHaveBeenNthCalledWith(1, message); | ||
| expect(printSpy.mock.calls[1][0]).toContain('at Promise'); |
There was a problem hiding this comment.
at <Method call> is used to detect stack trace.
| } | ||
|
|
||
| return factory.createNodeArray([...imports, ...errors, backendStatement, ...nodes], true); | ||
| return factory.createNodeArray([...imports, newLineIdentifier, ...errors, newLineIdentifier, backendStatement, ...nodes], true); |
There was a problem hiding this comment.
Nice! We should do it in category specific resource.ts files too (in next CR)
There was a problem hiding this comment.
nvm, saw later you have it already
| } | ||
| }); | ||
|
|
||
| it('should print error with debug flag', async () => { |
There was a problem hiding this comment.
Good question. Its not a boolean flag, the presence of --debug indicates its true and absence is false.
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('should print error without debug flag', async () => { |
| `Source code for this function can be found in your Amplify Gen 1 Directory. See .amplify/migration/amplify/backend/function/${definition.resourceName}/src`, | ||
| ), | ||
| ]), | ||
| factory.createExpressionStatement( |
There was a problem hiding this comment.
We should also wrap other throw new Error in createExpressionStatement(). We've some instances in backend.ts and also auth/resource.ts
There was a problem hiding this comment.
Good call out. Will do it other places too.
Description of changes
PreTokenGenerationConfigkey from Cognito duringpreparethrow new Errorcall expression in a statement. This adds a semicolon at the end@types/nodeto fixprocess.envtype errorspreparecommand--debugflag forpreparecommand to output the stack traceDescription of how you validated changes
local testing with
prepare,executeandrevertcommandsChecklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.