Closed workfel closed 7 years ago
Hi,
I use a command for make a request, but during the command i have an error. So i wrapping my code with try catch and i want to send the error in response body. But no error was displayed. Only error 500.
try catch
{ "tenant": "vulcain", "schema": "User", "action": "createuser", "domain": "madelink", "status": "Error", "correlationId": "a310c885a95640ce8bddb4b8aac05a07", "error": {} }
My command:
@Command({ executionTimeoutInMilliseconds: 3500 }) class UserCreationKeycloakCommand extends AbstractHttpCommand implements IUserCreationKeycloakCommand { private myvalue: IDynamicProperty<string>; constructor( @Inject(DefaultServiceNames.Container) container: IContainer, @Inject('KeycloakService') private service: KeycloakService) { super(container); } // Execute command async runAsync(user: User): Promise<UserKeycloak> { let client: KeycloakClient = await this.service.onConnectAdminClientAsync(); try { let clientCreated = await client.users.create(this.service.realmKeycloak, this.service.convertUser(user)); return clientCreated; } catch (error) { console.log('Error create user keycloak', error); throw error; } } }
And my handler:
@Action({ description: "Create a new user.", outputSchema: "any", inputSchema: "User" }) // action = method name (minus Async) async createUserAsync(user: User): Promise<any> { // Creation in keycloak const cmd = await this.createCommandAsync("UserCreationKeycloakCommand"); let userKeycloakCreated = await cmd.runAsync<UserKeycloak>(user); return { keycloak: userKeycloakCreated }; }
Thx
error must have a 'message' property
Yes, thank you, it's working
Hi,
I use a command for make a request, but during the command i have an error. So i wrapping my code with
try catch
and i want to send the error in response body. But no error was displayed. Only error 500.My command:
And my handler:
Thx