mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 22:58:01 +08:00
Rationalize exception management
This commit is contained in:
parent
478c0c41c6
commit
cd3b274112
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2017 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.spring.initializr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base Initializr exception.
|
|
||||||
*
|
|
||||||
* @author Stephane Nicoll
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class InitializrException extends RuntimeException {
|
|
||||||
|
|
||||||
public InitializrException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InitializrException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import io.spring.initializr.metadata.InitializrMetadata;
|
import io.spring.initializr.metadata.InitializrMetadata;
|
||||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||||
import io.spring.initializr.metadata.TypeCapability;
|
import io.spring.initializr.metadata.TypeCapability;
|
||||||
import io.spring.initializr.web.InvalidProjectRequestException;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeanWrapperImpl;
|
import org.springframework.beans.BeanWrapperImpl;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.spring.initializr.web;
|
package io.spring.initializr.web.project;
|
||||||
|
|
||||||
import io.spring.initializr.InitializrException;
|
import io.spring.initializr.generator.project.ProjectGenerationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when a {@link ProjectRequest} is invalid.
|
* Thrown when a {@link ProjectRequest} is invalid.
|
||||||
@ -24,11 +24,7 @@ import io.spring.initializr.InitializrException;
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class InvalidProjectRequestException extends InitializrException {
|
public class InvalidProjectRequestException extends ProjectGenerationException {
|
||||||
|
|
||||||
public InvalidProjectRequestException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvalidProjectRequestException(String message) {
|
public InvalidProjectRequestException(String message) {
|
||||||
super(message);
|
super(message);
|
@ -25,7 +25,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.spring.initializr.InitializrException;
|
|
||||||
import io.spring.initializr.generator.buildsystem.Build;
|
import io.spring.initializr.generator.buildsystem.Build;
|
||||||
import io.spring.initializr.generator.buildsystem.BuildItemResolver;
|
import io.spring.initializr.generator.buildsystem.BuildItemResolver;
|
||||||
import io.spring.initializr.generator.project.DefaultProjectAssetGenerator;
|
import io.spring.initializr.generator.project.DefaultProjectAssetGenerator;
|
||||||
@ -92,7 +91,7 @@ public class ProjectGenerationInvoker {
|
|||||||
addTempFile(name, file);
|
addTempFile(name, file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
catch (ProjectGenerationException | InitializrException ex) {
|
catch (ProjectGenerationException ex) {
|
||||||
publishProjectFailedEvent(request, metadata, ex);
|
publishProjectFailedEvent(request, metadata, ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ public class ProjectGenerationInvoker {
|
|||||||
projectGenerationContext, metadata));
|
projectGenerationContext, metadata));
|
||||||
return projectGenerator.generate(projectDescription, generateBuild(request));
|
return projectGenerator.generate(projectDescription, generateBuild(request));
|
||||||
}
|
}
|
||||||
catch (ProjectGenerationException | InitializrException ex) {
|
catch (ProjectGenerationException ex) {
|
||||||
publishProjectFailedEvent(request, metadata, ex);
|
publishProjectFailedEvent(request, metadata, ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import io.spring.initializr.metadata.DefaultMetadataElement;
|
|||||||
import io.spring.initializr.metadata.Dependency;
|
import io.spring.initializr.metadata.Dependency;
|
||||||
import io.spring.initializr.metadata.InitializrMetadata;
|
import io.spring.initializr.metadata.InitializrMetadata;
|
||||||
import io.spring.initializr.metadata.Type;
|
import io.spring.initializr.metadata.Type;
|
||||||
import io.spring.initializr.web.InvalidProjectRequestException;
|
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import io.spring.initializr.generator.project.ProjectDescription;
|
|||||||
import io.spring.initializr.generator.spring.test.InitializrMetadataTestBuilder;
|
import io.spring.initializr.generator.spring.test.InitializrMetadataTestBuilder;
|
||||||
import io.spring.initializr.generator.version.Version;
|
import io.spring.initializr.generator.version.Version;
|
||||||
import io.spring.initializr.metadata.InitializrMetadata;
|
import io.spring.initializr.metadata.InitializrMetadata;
|
||||||
import io.spring.initializr.web.InvalidProjectRequestException;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
Loading…
Reference in New Issue
Block a user