Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GenDB3
lib.dbxref
Commits
1efb258b
Commit
1efb258b
authored
Mar 03, 2015
by
Lukas Jelonek
Browse files
Improved error message when a url is not available anymore
parent
26bd1f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/cebitec/common/dbxref/api/AbstractResource.java
View file @
1efb258b
...
...
@@ -20,8 +20,6 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URI
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.apache.commons.io.IOUtils
;
/**
...
...
@@ -44,16 +42,15 @@ public abstract class AbstractResource implements Resource {
@Override
public
String
getResourceText
()
{
try
{
HttpURLConnection
openC
onnection
=
(
HttpURLConnection
)
uri
.
toURL
().
openConnection
();
openC
onnection
.
connect
();
int
responseCode
=
openC
onnection
.
getResponseCode
();
openC
onnection
.
disconnect
();
HttpURLConnection
c
onnection
=
(
HttpURLConnection
)
uri
.
toURL
().
openConnection
();
c
onnection
.
connect
();
int
responseCode
=
c
onnection
.
getResponseCode
();
c
onnection
.
disconnect
();
if
(
responseCode
>=
400
)
{
throw
new
UnsupportedOperationException
(
"
Invalid url
"
);
throw
new
UnsupportedOperationException
(
"
Can't access "
+
uri
+
" Return code ["
+
responseCode
+
"]
"
);
}
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
AbstractResource
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
throw
new
RuntimeException
(
ex
);
throw
new
RuntimeException
(
"Error accessing "
+
uri
,
ex
);
}
try
(
InputStream
stream
=
uri
.
toURL
().
openStream
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment