Skip to content

Commit

Permalink
thunderpay-api: billing[BillingExceptionBase]
Browse files Browse the repository at this point in the history
  • Loading branch information
krishpranav committed Jan 8, 2025
1 parent 3d9b46b commit 5956356
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
/**
* @file BillingExceptionBase.java
* @author Krisna Pranav
* @brief Billing Exception Base
* @version 1.0
* @date 2024-11-25
*
* @copyright Copyright (c) 2024 ThunderPayment Developers, Krisna Pranav
*
*/

package org.thunderpay.billing;

public class BillingExceptionBase extends Exception{
public class BillingExceptionBase extends Exception {

private static final long serialVersionUID = 165720101383L;

private final Throwable cause;
private final int code;
private final String formattedMsg;


public BillingExceptionBase(final Throwable cause, final int code, final String msg) {
this.cause = cause;
this.code = code;
this.formattedMsg = msg;
}

public BillingExceptionBase(final BillingExceptionBase cause) {
this(cause, cause.getCode(), cause.getMessage());
}

public BillingExceptionBase(final Throwable cause, final ErrorCode code, final Object... args) {
this(cause, code.getCode(), String.format(code.getFormat(), args));
}

public BillingExceptionBase(final ErrorCode code, final Object... args) {
this(null, code, args);
}

@Override
public String getMessage() {
return formattedMsg;
Expand All @@ -37,8 +60,4 @@ public String toString() {
sb.append('}');
return sb.toString();
}

public BillingExceptionBase(final BillingExceptionBase cause) {
this(cause, cause.getCode(), cause.getMessage());
}
}

0 comments on commit 5956356

Please sign in to comment.