Skip to content

Commit

Permalink
thunderpay-api: billing[ErrorCode]
Browse files Browse the repository at this point in the history
  • Loading branch information
krishpranav committed Jan 8, 2025
1 parent 99e5d0f commit bc1a01d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions thunderpay-api/src/main/java/org/thunderpay/billing/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}

0 comments on commit bc1a01d

Please sign in to comment.