package org.wikiwebserver.handler.http;

import java.io.IOException;

public class HTTPException extends IOException {
        
    private static final long serialVersionUID = 1L;
    
    private final int code;
    private final HTTPHeaders headers;
    

    public HTTPException(int code, String info) {
        this(code, info, (HTTPHeaders)null);
    }
    
    public HTTPException(int code, String info, Throwable cause) {
        this(code, info, (HTTPHeaders)null, cause);
    }    

    public HTTPException(int code, String info, HTTPHeaders headers) {
        super(info);
        this.code = code;
        this.headers = headers;
    }
    
    public HTTPException(int code, String info, HTTPHeaders headers, Throwable cause) {
        super(info, cause);
        this.code = code;
        this.headers = headers;
    }    
    
    public HTTPException(int code, String info, String url) {
        super(info);
        this.code = code;
        this.headers = new HTTPHeaders();
        url = url.replace("\n", "");
        headers.set("Location", url);
    }            

    public int getCode() {
        return this.code;
    }
    
    public HTTPHeaders getHeaders() {
        return headers;
    }
}

