Skip to content

Commit

Permalink
[FAB-4260] Update example_cc with FAB-3235 changes.
Browse files Browse the repository at this point in the history
Change-Id: I1c401143832885388d38917ad222ae0305a168b7
Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
  • Loading branch information
Luis Sanchez authored and cr22rc committed May 31, 2017
1 parent fd04683 commit 9f670a6
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
package example;

import static java.lang.String.format;
import static org.hyperledger.fabric.shim.ChaincodeHelper.newBadRequestResponse;
import static org.hyperledger.fabric.shim.ChaincodeHelper.newInternalServerErrorResponse;
import static org.hyperledger.fabric.shim.ChaincodeHelper.newSuccessResponse;

import java.io.PrintWriter;
import java.io.StringWriter;
Expand All @@ -31,7 +28,6 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.protos.peer.ProposalResponsePackage.Response;
import org.hyperledger.fabric.shim.ChaincodeBase;
import org.hyperledger.fabric.shim.ChaincodeStub;

Expand All @@ -49,14 +45,14 @@ public Response init(ChaincodeStub stub) {
case "init":
return init(stub, args.stream().skip(0).toArray(String[]::new));
default:
return newBadRequestResponse(format("Unknown function: %s", args.get(0)));
return newErrorResponse(format("Unknown function: %s", args.get(0)));
}
} catch (NumberFormatException e) {
return newBadRequestResponse(e.toString());
return newErrorResponse(e.toString());
} catch (IllegalArgumentException e) {
return newBadRequestResponse(e.getMessage());
return newErrorResponse(e.getMessage());
} catch (Throwable e) {
return newInternalServerErrorResponse(e);
return newErrorResponse(e);
}
}

Expand Down Expand Up @@ -86,15 +82,15 @@ public Response invoke(ChaincodeStub stub) {
case "query":
return query(stub, args);
default:
return newBadRequestResponse(newErrorJson("Unknown function: %s", function));
return newErrorResponse(newErrorJson("Unknown function: %s", function));
}

} catch (NumberFormatException e) {
return newBadRequestResponse(e.toString());
return newErrorResponse(e.toString());
} catch (IllegalArgumentException e) {
return newBadRequestResponse(e.getMessage());
return newErrorResponse(e.getMessage());
} catch (Throwable e) {
return newInternalServerErrorResponse(e);
return newErrorResponse(e);
}

}
Expand All @@ -114,7 +110,7 @@ private Response invoke(ChaincodeStub stub, String[] args) {
stub.delState(arg);
return newSuccessResponse();
default:
return newBadRequestResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction));
return newErrorResponse(newErrorJson("Unknown invoke sub-function: %s", subFunction));
}
}

Expand Down

0 comments on commit 9f670a6

Please sign in to comment.