package com.mojang.realmsclient.exception;

import net.minecraft.client.resources.language.I18n;
import com.mojang.realmsclient.client.RealmsError;

public class RealmsServiceException extends Exception {
    public final int httpResultCode;
    public final String httpResponseContent;
    public final int errorCode;
    public final String errorMsg;
    
    public RealmsServiceException(final int integer, final String string, final RealmsError dic) {
        super(string);
        this.httpResultCode = integer;
        this.httpResponseContent = string;
        this.errorCode = dic.getErrorCode();
        this.errorMsg = dic.getErrorMessage();
    }
    
    public RealmsServiceException(final int integer1, final String string2, final int integer3, final String string4) {
        super(string2);
        this.httpResultCode = integer1;
        this.httpResponseContent = string2;
        this.errorCode = integer3;
        this.errorMsg = string4;
    }
    
    @Override
    public String toString() {
        if (this.errorCode == -1) {
            return "Realms (" + this.httpResultCode + ") " + this.httpResponseContent;
        }
        final String string2 = "mco.errorMessage." + this.errorCode;
        final String string3 = I18n.get(string2);
        return (string3.equals(string2) ? this.errorMsg : string3) + " - " + this.errorCode;
    }
}
