Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/DigestHelper.java @ 423:9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 23 Mar 2012 22:51:18 +0100 |
parents | 981f9f50bb6c |
children |
comparison
equal
deleted
inserted
replaced
422:5d1cc7366d04 | 423:9c9c442b5f2e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 TMate Software Ltd | 2 * Copyright (c) 2010-2012 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
19 import java.io.IOException; | 19 import java.io.IOException; |
20 import java.io.InputStream; | 20 import java.io.InputStream; |
21 import java.security.MessageDigest; | 21 import java.security.MessageDigest; |
22 import java.security.NoSuchAlgorithmException; | 22 import java.security.NoSuchAlgorithmException; |
23 | 23 |
24 import org.tmatesoft.hg.core.HgBadStateException; | |
25 import org.tmatesoft.hg.core.Nodeid; | 24 import org.tmatesoft.hg.core.Nodeid; |
25 import org.tmatesoft.hg.repo.HgInvalidStateException; | |
26 | 26 |
27 | 27 |
28 /** | 28 /** |
29 * <pre> | 29 * <pre> |
30 * DigestHelper dh; | 30 * DigestHelper dh; |
48 if (sha1 == null) { | 48 if (sha1 == null) { |
49 try { | 49 try { |
50 sha1 = MessageDigest.getInstance("SHA-1"); | 50 sha1 = MessageDigest.getInstance("SHA-1"); |
51 } catch (NoSuchAlgorithmException ex) { | 51 } catch (NoSuchAlgorithmException ex) { |
52 // could hardly happen, JDK from Sun always has sha1. | 52 // could hardly happen, JDK from Sun always has sha1. |
53 throw new HgBadStateException(ex); | 53 HgInvalidStateException t = new HgInvalidStateException("Need SHA-1 algorithm for nodeid calculation"); |
54 t.initCause(ex); | |
55 throw t; | |
54 } | 56 } |
55 } | 57 } |
56 return sha1; | 58 return sha1; |
57 } | 59 } |
58 | 60 |