-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance error reporting for failed gRPC client stub creation. (#5387)
Motivation: I got a report that it's not easy to trouble shoot when an exception is raised while creating a gRPC client stub because the exception is swallowed currently. Modification: - Introduce `ServiceDescriptorResolutionException` to capture exceptions raised during the invocation of `GrpcClientStubFactory#findServiceDescriptor(Class)` within Armeria's built-in factories. - Store these exceptions and display them to the user if `GrpcClientFactory` fails to create the client stub. Result: - You can now easily identify issues when failing to create a gRPC client stub.
- Loading branch information
Showing
6 changed files
with
83 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../java/com/linecorp/armeria/internal/client/grpc/ServiceDescriptorResolutionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2024 LINE Corporation | ||
* | ||
* LINE Corporation licenses this file to you 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: | ||
* | ||
* https://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 com.linecorp.armeria.internal.client.grpc; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import com.linecorp.armeria.client.grpc.GrpcClientStubFactory; | ||
|
||
/** | ||
* A wrapper exception for propagating exceptions raised during the invocation of | ||
* {@link GrpcClientStubFactory#findServiceDescriptor(Class)} within Armeria's built-in factories. | ||
* Note that this class is for internal use thus it's not exposed to users. | ||
*/ | ||
public final class ServiceDescriptorResolutionException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -4062645240586772465L; | ||
private final String stubFactoryName; | ||
|
||
public ServiceDescriptorResolutionException(String stubFactoryName, Throwable cause) { | ||
super(requireNonNull(cause, "cause")); | ||
this.stubFactoryName = requireNonNull(stubFactoryName, "stubFactoryName"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return stubFactoryName + '=' + getCause().toString(); | ||
} | ||
} |