com.streamsets.pipeline.api.ErrorCode Maven / Gradle / Ivy
The newest version!
/*
* Copyright contributors to the StreamSets project
* StreamSets Inc., an IBM Company 2024
*
* 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.streamsets.pipeline.api;
/**
*
* Typifies error codes with built-in localization support. Pipeline exceptions use error codes.
*
* Error code implementations are typically enums, i.e.:
*
*
*
* public enum Errors implements ErrorCode {
* API_00("This is a human readable error message", "This is a technical error message", "this is the remediation steps", "this is the technical metadata"),
* ;
*
* private final String humanReadableMessage;
* private final String technicalMessage;
* private final String remediationSteps;
*
* Errors(String humanReadableMessage) {
* this(humanReadableMessage, "", "");
* }
*
* Errors(String humanReadableMessage, String technicalMessage, String remediationSteps, Map
*
*
* Built in localization looks for a Properties based ResourceBundle matching the
* ErrorCode implementation. The ErrorCode's code is used as the key within the
* ResourceBundle. If the bundle is not available, or the key is not defined within the bundle, the
* ErrorCode's message will be used.
*
* Typically, the message can be a template, using {} as positional placeholders for values.
* {@link com.streamsets.pipeline.api.StageException} take an ErrorCode plus variable arguments on its
* constructors and generates the exception message using the ErrorCode message as template then variable
* argument as the values for it.
*/
public interface ErrorCode {
/**
* Returns the error code.
*
* @return the error code.
*/
String getCode();
/**
* Returns the built-in default message for the error code.
*
* @return the default message template
*/
String getMessage();
default String getTechnicalMessage() {
return getMessage();
}
default String getRemediationSteps() {
return "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy