Skip to content

Commit 58c6a68

Browse files
Ivan MaretićJulusian
authored andcommitted
feat: return adlib action validation errors to client
1 parent af79699 commit 58c6a68

4 files changed

Lines changed: 6 additions & 29 deletions

File tree

meteor/server/api/rest/v1/playlists.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,6 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
301301
}
302302
)
303303
if (ClientAPI.isClientResponseError(result)) return result
304-
// Check if the action rejected the request
305-
if (result.result?.errorMessage) {
306-
return ClientAPI.responseError(
307-
UserError.from(
308-
new Error(result.result.errorMessage),
309-
UserErrorMessage.InternalError,
310-
undefined,
311-
400
312-
)
313-
)
314-
}
315304
return ClientAPI.responseSuccess(result.result ?? {})
316305
} else {
317306
return ClientAPI.responseError(
@@ -383,12 +372,6 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
383372
}
384373
)
385374
if (ClientAPI.isClientResponseError(result)) return result
386-
// Check if the action rejected the request
387-
if (result.result?.errorMessage) {
388-
return ClientAPI.responseError(
389-
UserError.from(new Error(result.result.errorMessage), UserErrorMessage.InternalError, undefined, 400)
390-
)
391-
}
392375
return ClientAPI.responseSuccess(result.result ?? {})
393376
}
394377

packages/corelib/src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const UserErrorMessagesTranslations: { [key in UserErrorMessage]: string } = {
116116
[UserErrorMessage.DeviceAlreadyAttachedToStudio]: t(`Device is already attached to another studio.`),
117117
[UserErrorMessage.ShowStyleBaseNotFound]: t(`ShowStyleBase not found!`),
118118
[UserErrorMessage.NoMigrationsToApply]: t(`No migrations to apply`),
119-
[UserErrorMessage.ValidationFailed]: t('Validation failed!'),
119+
[UserErrorMessage.ValidationFailed]: t('Validation failed! {{message}}'),
120120
[UserErrorMessage.AdlibTestingNotAllowed]: t(`Rehearsal mode is not allowed`),
121121
[UserErrorMessage.AdlibTestingAlreadyActive]: t(`Rehearsal mode is already active`),
122122
[UserErrorMessage.BucketNotFound]: t(`Bucket not found!`),

packages/corelib/src/worker/studio.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,6 @@ export interface ExecuteBucketAdLibOrActionProps extends RundownPlayoutPropsBase
284284
externalId: string
285285
triggerMode?: string
286286
}
287-
export interface ExecuteBucketAdLibOrActionProps extends RundownPlayoutPropsBase {
288-
bucketId: BucketId
289-
externalId: string
290-
triggerMode?: string
291-
}
292287
export interface ExecuteActionResult {
293288
queuedPartInstanceId?: PartInstanceId
294289
taken?: boolean

packages/job-worker/src/playout/adlibAction.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ export async function executeActionInner(
271271
throw UserError.fromUnknown(err)
272272
}
273273

274-
if (result && result.validationErrors) {
274+
const validationErrors = result?.validationErrors ?? actionContext.requestError
275+
if (validationErrors) {
276+
const message = typeof validationErrors === 'string' ? validationErrors : JSON.stringify(validationErrors)
275277
throw UserError.from(
276-
new Error(
277-
`AdLib Action "${actionParameters.actionId}" validation failed: ${JSON.stringify(result.validationErrors)}`
278-
),
278+
new Error(`AdLib Action "${actionParameters.actionId}" validation failed: ${message}`),
279279
UserErrorMessage.ValidationFailed,
280-
undefined,
280+
{ message },
281281
409
282282
)
283283
}
@@ -296,7 +296,6 @@ export async function executeActionInner(
296296
return {
297297
queuedPartInstanceId: actionContext.queuedPartInstanceId,
298298
taken: actionContext.takeAfterExecute,
299-
errorMessage: actionContext.requestError,
300299
}
301300
}
302301

0 commit comments

Comments
 (0)