/** * Copyright (C) 2017-2018 Christian Pierre MOMON * Copyright (C) 2011-2013 Nicolas Vinot * * This file is part of (April) Hebdobot. * * Hebdobot is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Hebdobot is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Hebdobot. If not, see */ package org.april.hebdobot.pastebin; public class APIException extends Exception { private static final long serialVersionUID = 1852384776503676687L; /** * Instantiates a new API exception. * * @param message * the message */ private APIException(final String message) { super(message); } /** * Throw if error. * * @param content * the content * @throws APIException * the API exception */ public static void throwIfError(final String content) throws APIException { if (content.contains(PastebinClient.API_ERROR)) { throw new APIException(content.replaceFirst(PastebinClient.API_ERROR, "")); } } }