Skip to content

Commit

Permalink
[Application Service] Improve after-setup error message (elastic#191170)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Aug 23, 2024
1 parent 753f3d9 commit 745ecfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ describe('#setup()', () => {
await service.start(startDeps);
expect(() =>
register(Symbol(), createApp({ id: 'app1' }))
).toThrowErrorMatchingInlineSnapshot(`"Applications cannot be registered after \\"setup\\""`);
).toThrowErrorMatchingInlineSnapshot(
`"Applications cannot be registered after \\"setup\\" (attempted to register \\"app1\\")"`
);
});

it('allows to register an AppUpdater for the application', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export class ApplicationService {

const validateApp = (app: App<unknown>) => {
if (this.registrationClosed) {
throw new Error(`Applications cannot be registered after "setup"`);
throw new Error(
`Applications cannot be registered after "setup" (attempted to register "${app.id}")`
);
} else if (!applicationIdRegexp.test(app.id)) {
throw new Error(
`Invalid application id: it can only be composed of alphanum chars, '-' and '_'`
Expand Down

0 comments on commit 745ecfd

Please sign in to comment.