All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dell.cpsd.common.rabbitmq.exceptions.ApplicationException Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
/**
 * Copyright © 2017 Dell Inc. or its subsidiaries.  All Rights Reserved.
 * Dell EMC Confidential/Proprietary Information
 */


package com.dell.cpsd.common.rabbitmq.exceptions;

import com.dell.cpsd.common.rabbitmq.i18n.error.LocalizedError;
import com.dell.cpsd.common.rabbitmq.i18n.error.LocalizedErrorCode;
import com.dell.cpsd.common.rabbitmq.i18n.error.LocalizedErrorsProvider;

import java.util.ArrayList;
import java.util.List;

import static java.util.Arrays.asList;

/**
 * Base implementation of application-specific exception with localized messages.
 * 

* Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved. * Dell EMC Confidential/Proprietary Information *

*/ public class ApplicationException extends RuntimeException implements LocalizedErrorsProvider { private static final long serialVersionUID = -580003631209011147L; private List errors; public ApplicationException(LocalizedErrorCode localizedErrorCode, Object... params) { this(null, localizedErrorCode.getLocalizedError(params)); } public ApplicationException(Throwable cause, LocalizedErrorCode localizedErrorCode, Object... params) { this(cause, localizedErrorCode.getLocalizedError(params)); } public ApplicationException(LocalizedError error) { this(null, asList(error)); } public ApplicationException(Throwable cause, LocalizedError error) { this(cause, asList(error)); } public ApplicationException(List errors) { this(null, errors); } public ApplicationException(Throwable cause, List errors) { super(getFirstLocalizedMessage(errors), cause); this.errors = new ArrayList<>(errors); } protected static String getFirstLocalizedMessage(List errors) { return (errors == null || errors.isEmpty()) ? null : errors.get(0).getMessage(); } @Override public List getLocalizedErrors() { return errors; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy