Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2024 The Dapr Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
limitations under the License.
*/
package io.dapr.exceptions;
import com.google.protobuf.Any;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.rpc.Status;
import io.dapr.utils.TypeRef;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public class DaprErrorDetails {
static final DaprErrorDetails EMPTY_INSTANCE = new DaprErrorDetails((Status) null);
private static final Map, ErrorDetailType> SUPPORTED_ERROR_TYPES =
Collections.unmodifiableMap(new HashMap<>() {
{
put(com.google.rpc.ErrorInfo.class, ErrorDetailType.ERROR_INFO);
put(com.google.rpc.RetryInfo.class, ErrorDetailType.RETRY_INFO);
put(com.google.rpc.DebugInfo.class, ErrorDetailType.DEBUG_INFO);
put(com.google.rpc.QuotaFailure.class, ErrorDetailType.QUOTA_FAILURE);
put(com.google.rpc.PreconditionFailure.class, ErrorDetailType.PRECONDITION_FAILURE);
put(com.google.rpc.BadRequest.class, ErrorDetailType.BAD_REQUEST);
put(com.google.rpc.RequestInfo.class, ErrorDetailType.REQUEST_INFO);
put(com.google.rpc.ResourceInfo.class, ErrorDetailType.RESOURCE_INFO);
put(com.google.rpc.Help.class, ErrorDetailType.HELP);
put(com.google.rpc.LocalizedMessage.class, ErrorDetailType.LOCALIZED_MESSAGE);
}
});
private static final Map> ERROR_TYPES_FQN_REVERSE_LOOKUP =
SUPPORTED_ERROR_TYPES.keySet().stream().collect(Collectors.toMap(
item -> generateErrorTypeFqn(item),
item -> item
));
/**
* Error status details.
*/
private final Map> map;
public DaprErrorDetails(Status grpcStatus) {
this.map = parse(grpcStatus);
}
public DaprErrorDetails(List