Use exceptions with explicit messages

This commit is contained in:
René Pfeuffer
2020-03-25 15:31:20 +01:00
parent af45388c27
commit 7247a81c9d
8 changed files with 104 additions and 20 deletions

View File

@@ -21,11 +21,21 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.plugin;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
public class PluginChecksumMismatchException extends PluginInstallException {
public PluginChecksumMismatchException(String message) {
super(message);
public PluginChecksumMismatchException(AvailablePlugin plugin, String calculatedChecksum, String expectedChecksum) {
super(
entity("Plugin", plugin.getDescriptor().getInformation().getName()).build(),
String.format("downloaded plugin checksum %s does not match expected %s", calculatedChecksum, expectedChecksum)
);
}
@Override
public String getCode() {
return "6mRuFxaWM1";
}
}