From bc1a01da4e9b13c3dbc8449ca1055a6930f42c6e Mon Sep 17 00:00:00 2001 From: Krisna Pranav <68631244+krishpranav@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:27:03 +0530 Subject: [PATCH] thunderpay-api: billing[ErrorCode] --- .../main/java/org/thunderpay/billing/ErrorCode.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/thunderpay-api/src/main/java/org/thunderpay/billing/ErrorCode.java b/thunderpay-api/src/main/java/org/thunderpay/billing/ErrorCode.java index da7e9bc..8996ccf 100644 --- a/thunderpay-api/src/main/java/org/thunderpay/billing/ErrorCode.java +++ b/thunderpay-api/src/main/java/org/thunderpay/billing/ErrorCode.java @@ -12,6 +12,8 @@ package org.thunderpay.billing; public enum ErrorCode { + + __UNKNOWN_EROR_CODE(-1, "Unknown error code"); private final int code; private final String format; @@ -27,4 +29,14 @@ public String getFormat() { public int getCode() { return code; } + + public static ErrorCode fromCode(final int code) { + for(final ErrorCode errorCode : ErrorCode.values()) { + if (errorCode.getCode() == code) { + return errorCode; + } + } + + return __UNKNOWN_EROR_CODE; + } }