Package com.alibaba.dashscope.errors
Class Errors
java.lang.Object
com.alibaba.dashscope.errors.Errors
Registry-driven error factory (design §5). Four entries:
fromStatus(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object, java.util.Map<java.lang.String, java.lang.String>) for non-2xx HTTP,
fromBusinessCode(java.lang.String, java.lang.String, java.lang.String, java.lang.Object, java.util.Map<java.lang.String, java.lang.String>) for the HTTP-200-with-business-code layer, fromSdkErrorCode(com.alibaba.dashscope.errors.SdkErrorCode, java.util.Map<java.lang.String, java.lang.String>)
for SDK-side failures, and fromCatalogEntry(com.alibaba.dashscope.errors.PublicErrorCode, java.lang.String, java.lang.String, java.lang.Object, java.util.Map<java.lang.String, java.lang.String>, java.lang.Throwable) for SDK-side response-shape failures that
carry a public catalog code. Unmapped wire codes are never guessed into a subclass: they land on
plain ApiStatusException.
Class selection is catalog-driven: the wire-code crosswalk only picks which PublicErrorCode applies, and the exception class comes from that entry. The single sanctioned
refinement is DataInspectionFailed → ContentFilterException (subclass of the
class its catalog entry names).
-
Method Summary
Modifier and TypeMethodDescriptionstatic ApiConnectionExceptionconnection(SdkErrorCode entry, String detail, Throwable cause) SDK-side connection failure from the catalog, keeping theApiConnectionExceptiontype.static ApiStatusExceptionfromBusinessCode(String code, String message, String requestId, Object body, Map<String, String> headers) Map the HTTP-200-with-business-code layer.static ApiStatusExceptionfromCatalogEntry(PublicErrorCode entry, String message, String requestId, Object body, Map<String, String> headers, Throwable cause) Public catalog entry raised verbatim for an SDK-side response-shape failure (an unparseable or malformed 2xx body).static SdkExceptionfromSdkErrorCode(SdkErrorCode entry) static SdkExceptionfromSdkErrorCode(SdkErrorCode entry, Map<String, String> vars) SDK-side failure straight from the catalog.static SdkExceptionfromSdkErrorCode(String code, String message, Throwable cause) Translate a mount-layer subsystem exception into the 3.0 family.static ApiStatusExceptionfromStatus(int statusCode, String code, String message, String requestId, Object body, Map<String, String> headers) Map a non-2xx HTTP response into the exception family.static SdkExceptionfromThrowable(Throwable exc, String family) static SdkExceptionio(SdkErrorCode entry, String detail, Throwable cause) SDK-side local I/O failure from the catalog, kept as plainSdkException: a filesystem failure is not a connection problem, so it must not masquerade asApiConnectionException.static ApiTimeoutExceptiontimeout(SdkErrorCode entry, String detail, Throwable cause) SDK-side timeout from the catalog, keeping theApiTimeoutExceptiontype.
-
Method Details
-
fromStatus
public static ApiStatusException fromStatus(int statusCode, String code, String message, String requestId, Object body, Map<String, String> headers) Map a non-2xx HTTP response into the exception family. -
fromBusinessCode
public static ApiStatusException fromBusinessCode(String code, String message, String requestId, Object body, Map<String, String> headers) Map the HTTP-200-with-business-code layer. Status is pinned to 200 so callers can tell which layer failed. -
fromCatalogEntry
public static ApiStatusException fromCatalogEntry(PublicErrorCode entry, String message, String requestId, Object body, Map<String, String> headers, Throwable cause) Public catalog entry raised verbatim for an SDK-side response-shape failure (an unparseable or malformed 2xx body). The exchange itself succeeded, sofromStatus(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object, java.util.Map<java.lang.String, java.lang.String>)'s status→class crosswalk must not run: it would fabricate e.g.InternalServerExceptionand a statusCode of 500 for an exchange that returned 200. The exception stays a plainApiStatusExceptionwithstatusCodenull —getStatusCode()'s contract is "HTTP status of the failed exchange; null for SDK-side failures" — and the originating parse/validation failure rides ascause. -
fromSdkErrorCode
SDK-side failure straight from the catalog. -
fromSdkErrorCode
-
connection
SDK-side connection failure from the catalog, keeping theApiConnectionExceptiontype.detailfills the entry's{detail}placeholder; passnullfor the raw template. -
timeout
SDK-side timeout from the catalog, keeping theApiTimeoutExceptiontype.detailfills the entry's{detail}placeholder; passnullfor the raw template. -
io
SDK-side local I/O failure from the catalog, kept as plainSdkException: a filesystem failure is not a connection problem, so it must not masquerade asApiConnectionException.detailfills the entry's{detail}placeholder; passnullfor the raw template. -
fromSdkErrorCode
Translate a mount-layer subsystem exception into the 3.0 family. Two-tier lookup:<family>.<ClassName>when the catalog carries that exact class, otherwise the family's<family>.Errorfallback. Message text and legacy numeric codes are never sniffed. -
fromThrowable
-