mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-06 06:39:15 +01:00
improve handling of startup error handling
This commit is contained in:
@@ -89,9 +89,16 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
*/
|
||||
public BasicContextProvider()
|
||||
{
|
||||
baseDirectory = findBaseDirectory();
|
||||
version = loadVersion();
|
||||
stage = loadProjectStage();
|
||||
try
|
||||
{
|
||||
baseDirectory = findBaseDirectory();
|
||||
version = loadVersion();
|
||||
stage = loadProjectStage();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
this.startupError = ex;
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -137,6 +144,18 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Throwable getStartupError()
|
||||
{
|
||||
return startupError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the SCM-Manager. If the version is not set, the
|
||||
* {@link #DEFAULT_VERSION} is returned.
|
||||
@@ -182,7 +201,16 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
|
||||
if (!directory.exists() &&!directory.mkdirs())
|
||||
{
|
||||
throw new IllegalStateException("could not create directory");
|
||||
String msg = "could not create home directory at ".concat(
|
||||
directory.getAbsolutePath());
|
||||
|
||||
// do not use logger
|
||||
// http://www.slf4j.org/codes.html#substituteLogger
|
||||
System.err.println("===================================================");
|
||||
System.err.append("Error: ").println(msg);
|
||||
System.err.println("===================================================");
|
||||
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
|
||||
return directory;
|
||||
@@ -319,6 +347,9 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
/** stage of the current SCM-Manager instance */
|
||||
private Stage stage;
|
||||
|
||||
/** startup exception */
|
||||
private Throwable startupError;
|
||||
|
||||
/** the version of the SCM-Manager */
|
||||
private String version;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,16 @@ public interface SCMContextProvider extends Closeable
|
||||
*/
|
||||
public Stage getStage();
|
||||
|
||||
/**
|
||||
* Returns a exception which is occurred on context startup.
|
||||
* The method returns null if the start was successful.
|
||||
*
|
||||
*
|
||||
* @return startup exception of null
|
||||
* @since 1.14
|
||||
*/
|
||||
public Throwable getStartupError();
|
||||
|
||||
/**
|
||||
* Returns the version of the SCM-Manager.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user