Skip to content

Commit

Permalink
Merge pull request #62 from basho/bugfix/sdc/61-pb-bucket-no-type-error
Browse files Browse the repository at this point in the history
Handle the {error, no_type} return from riak_core_bucket.

Reviewed-by: andrewjstone
  • Loading branch information
borshop committed May 29, 2014
2 parents 9da645b + ef62bef commit ba323da
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/riak_core_pb_bucket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,25 @@ encode(Message) ->
{ok, riak_pb_codec:encode(Message)}.

%% Get bucket properties
process(#rpbgetbucketreq{type = T, bucket=B}, State) ->
process(#rpbgetbucketreq{type=T, bucket=B}, State) ->
Bucket = maybe_create_bucket_type(T, B),
Props = riak_core_bucket:get_bucket(Bucket),
PbProps = riak_pb_codec:encode_bucket_props(Props),
{reply, #rpbgetbucketresp{props = PbProps}, State};
case riak_core_bucket:get_bucket(Bucket) of
{error, no_type} ->
{error, {format, "No bucket-type named '~s'", [T]}, State};
Props ->
PbProps = riak_pb_codec:encode_bucket_props(Props),
{reply, #rpbgetbucketresp{props = PbProps}, State}
end;

%% Set bucket properties
process(#rpbsetbucketreq{type = T, bucket=B, props = PbProps}, State) ->
process(#rpbsetbucketreq{type=T, bucket=B, props=PbProps}, State) ->
Props = riak_pb_codec:decode_bucket_props(PbProps),
Bucket = maybe_create_bucket_type(T, B),
case riak_core_bucket:set_bucket(Bucket, Props) of
ok ->
{reply, rpbsetbucketresp, State};
{error, no_type} ->
{error, {format, "No bucket-type named '~s'", [T]}, State};
{error, Details} ->
{error, {format, "Invalid bucket properties: ~p", [Details]}, State}
end;
Expand Down

0 comments on commit ba323da

Please sign in to comment.