vulcainjs / vulcain-corejs

Microservice framework for nodejs
https://vulcainjs.github.io
Apache License 2.0
11 stars 3 forks source link

Command no return error #20

Closed workfel closed 7 years ago

workfel commented 7 years ago

Hi,

I made a Http request from a AbstractHttpCommand class, during the request i have no response from it, and i have remove the fallbackAsyncmethod, and the server still pending on request.

It's mandatory to have the fallback method ?

To solve it i put trycatch, it's the good way, or the command should be this automatically ?

   async runAsync(user: User): Promise<RocketChatUser> {
        try {
            let userToCreate: RocketChatToCreateUser = this.service.convertUser(user);
            let response = await this.postAsync(`${this.hostRocketChatGateway.value}/api/user.createuser`, userToCreate);
            return response.body.value;
        } catch (error) {
            throw { message: error };
        }

    }

Thx

malain commented 7 years ago

Fallback must be provided only if you want a compensation. You do not have to catch an error in your command except to transform an error without a message property (which must be a string). In your example, you can remove the try..catch

workfel commented 7 years ago

Ok thank you. But in my example, if i remove the try catch the error are not returned. The server return

{
    "tenant": "vulcain",
    "schema": "User",
    "action": "createuser",
    "domain": "mydomain",
    "status": "Error",
    "correlationId": "59f2fcea4790452eac4673f4057b42eb",
    "error": {

    }
}

Because the error returned form HTTP request it's :

{ 
 "errorMessage" : "string"
}