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; + } }