Skip to content

Commit 1938e48

Browse files
Show migration submission rejection messages in text errors
1 parent 94a1efe commit 1938e48

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎packages/app/src/cli/commands/app/subscription-migrations/result-presenter.test.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,26 @@ describe('migration submission result presenter', () => {
202202
const result: MigrationSubmissionResult = {
203203
status: 'failed',
204204
submission: value,
205-
failure: {type: 'submission', batchIndex: 0, userErrors: [{message: 'App not found', field: ['apiKey']}]},
205+
failure: {
206+
type: 'submission',
207+
batchIndex: 0,
208+
userErrors: [
209+
{message: 'App not found', field: ['apiKey']},
210+
{message: 'Invalid plan', field: null},
211+
],
212+
},
206213
}
207214
expect(() => presentMigrationSubmissionResult(result, {json, watch: false})).toThrow(
208-
'Subscription migration submission failed.',
215+
expect.objectContaining({
216+
message: 'Subscription migration submission failed.\nApp not found\nInvalid plan',
217+
details: {
218+
batchIndex: 0,
219+
userErrors: [
220+
{message: 'App not found', fieldPath: ['apiKey']},
221+
{message: 'Invalid plan', fieldPath: null},
222+
],
223+
},
224+
}),
209225
)
210226
expect(outputResult).not.toHaveBeenCalled()
211227
},

‎packages/app/src/cli/commands/app/subscription-migrations/result-presenter.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export function presentMigrationSubmissionResult(
3030
options: SubmissionPresentationOptions,
3131
): 0 | 1 {
3232
if (result.status === 'failed' && result.submission.operations.length === 0) {
33-
const error = new AbortError('Subscription migration submission failed.')
33+
const message = [
34+
'Subscription migration submission failed.',
35+
...(result.failure.type === 'submission' ? result.failure.userErrors.map(({message}) => message) : []),
36+
].join('\n')
37+
const error = new AbortError(message)
3438
error.details =
3539
result.failure.type === 'submission'
3640
? {

0 commit comments

Comments
 (0)