All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jhonnymertz.wkhtmltopdf.wrapper.exceptions.PDFTimeoutException Maven / Gradle / Ivy

Go to download

A Java based wrapper for the wkhtmltopdf command line tool. As the name implies, it uses WebKit to convert HTML documents to PDFs.

There is a newer version: 1.3.1-RELEASE
Show newest version
package com.github.jhonnymertz.wkhtmltopdf.wrapper.exceptions;

/**
 * Exception to describe and track pdf exporting errors due to timeout
 */
public class PDFTimeoutException extends RuntimeException {

    /**
     * The PDF command which originated the exception
     */
    private String command;

    /**
     * The default exit status code for timeout of the PDF command
     */
    private int timeout;

    /**
     * The output of the PDF command
     */
    private byte[] out;

    /**
     * Instantiates a new Pdf timeout exception when wkhtmltopdf timeout happens
     *
     * @param command the command
     * @param timeout the timeout
     * @param out     the out
     */
    public PDFTimeoutException(final String command, final int timeout, final byte[] out) {
        super(String.format("Process '%s' timeout after %d seconds. " +
                "Try to increase the timeout via the 'PDF.setTimeout()' method.", command, timeout));
        this.command = command;
        this.timeout = timeout;
        this.out = out;
    }

    /**
     * Instantiates a new Pdf timeout exception when future process timeout happens
     *
     * @param timeout the timeout
     * @param e       the exception
     */
    public PDFTimeoutException(final int timeout, final Exception e) {
        super(String.format("Process timeout after %s seconds. " +
                "Try to increase the timeout via the 'PDF.setTimeout()' method.", timeout), e);
    }

    /**
     * Gets command.
     *
     * @return the command
     */
    public String getCommand() {
        return command;
    }

    /**
     * Gets exit status.
     *
     * @return the exit status
     */
    public int getExitStatus() {
        return 124;
    }

    /**
     * Get out byte [ ].
     *
     * @return the byte [ ]
     */
    public byte[] getOut() {
        return out;
    }

    /**
     * Get timeout.
     *
     * @return the timeout
     */
    public int getTimeout() {
        return timeout;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy