com.stormpath.spring.errors.CustomParameterizedException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stormpath-spring-webmvc Show documentation
Show all versions of stormpath-spring-webmvc Show documentation
Web MVC support for Stormpath-enabled Spring applications.
/*
* Copyright 2016 Stormpath, Inc.
*
* 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 com.stormpath.spring.errors;
/**
* Custom, parameterized exception, which can be translated on the client side.
* For example:
*
*
* throw new CustomParameterizedException("myCustomError", "hello", "world");
*
*
* Can be translated with:
*
*
* "error.myCustomError" : "The server says {{params[0]}} to {{params[1]}}"
*
*
* Copied with much respect from JHipster: https://github.com/jhipster/generator-jhipster/tree/master/generators/server/templates/src/main/java/package/web/rest/errors
*
* @since 1.0.0
*/
public class CustomParameterizedException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final String message;
private final String[] params;
public CustomParameterizedException(String message, String... params) {
super(message);
this.message = message;
this.params = params;
}
public ParameterizedError getErrorDTO() {
return new ParameterizedError(message, params);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy