hyperledger-labs / fabric-smart-client

The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web client needs to handle error responses

davidkel opened this issue · comments

In platform/view/services/client/web/client.go

	resp, err := c.c.Do(req)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to process http request to [%s], input length [%d]", url, len(in))
	}
	buff, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to read response from http request to [%s], input length [%d]", url, len(in))
	}

	response := &protos2.CommandResponse_CallViewResponse{}
	err = json.Unmarshal(buff, response)

always assumes that the response will be a callviewresponse but this may not be the case. For example if you try to send http to an https server or if both are http and you try to call a view the response isn't of the format and you get unhelpful messages about the response