2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.common.errors;
19 import org.apache.commons.text.RandomStringGenerator;
21 public class GeneralErrorBuilder {
23 private static final String GENERAL_ERROR_REST_ID = "GENERAL_ERROR_REST_ID";
24 private static final String GENERAL_ERROR_REST_MSG =
25 "An internal error has occurred. Please contact support. Error ID: %s";
27 private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
30 * Instantiates a new General error builder.
32 public GeneralErrorBuilder() {
33 RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('A', 'Z').build();
34 builder.withId(GENERAL_ERROR_REST_ID);
35 builder.withCategory(ErrorCategory.APPLICATION);
36 builder.withMessage(String.format(GENERAL_ERROR_REST_MSG, generator.generate(8)));
39 public ErrorCode build() {
40 return builder.build();