You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/04 20:04:37 UTC
[2/2] git commit: Use UnsupportedOperationException instead of custom
exception.
Use UnsupportedOperationException instead of custom exception.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4e4b9ce9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4e4b9ce9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4e4b9ce9
Branch: refs/heads/master
Commit: 4e4b9ce96e1a9da32a163b8bb8cb4b9c1d2b90b9
Parents: 8c4f9f1
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 13:03:09 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 13:03:09 2014 -0500
----------------------------------------------------------------------
.../log4j/io/IncompatibleLoggerException.java | 46 --------------------
.../apache/logging/log4j/io/LoggerStreams.java | 7 +--
2 files changed, 4 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4e4b9ce9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
deleted file mode 100644
index dad13fc..0000000
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.logging.log4j.io;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-/**
- * Indicates that a provided {@link org.apache.logging.log4j.Logger} does not implement {@link ExtendedLogger}.
- *
- * @since 2.1
- */
-public class IncompatibleLoggerException extends LoggingException {
-
- private static final long serialVersionUID = 6861427446876787666L;
-
- /**
- * Constructs a new IncompatibleLoggerException using the type of the provided Logger. If {@code logger} is
- * {@code null}, then the type is printed as "null". Note that this exception should only be thrown in situations
- * where a Logger was provided but did not implement ExtendedLogger.
- *
- * @param logger the provided Logger that was not an ExtendedLogger
- */
- public IncompatibleLoggerException(final Logger logger) {
- super(
- "Incompatible Logger class. Expected to implement " + ExtendedLogger.class.getName() + ". Got: "
- + (logger == null ? "null" : logger.getClass().getName())
- );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4e4b9ce9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
index 30b2324..6213811 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
@@ -72,8 +72,8 @@ public class LoggerStreams {
*
* @param logger the Logger to wrap into a LoggerStream
* @return a new LoggerStream builder
- * @throws IncompatibleLoggerException if {@code logger} does not implement {@link ExtendedLogger} or if
- * {@code logger} is {@code null}
+ * @throws UnsupportedOperationException if {@code logger} does not implement {@link ExtendedLogger} or if
+ * {@code logger} is {@code null}
*/
public static LoggerStreams forLogger(final Logger logger) {
return new LoggerStreams(logger);
@@ -105,7 +105,8 @@ public class LoggerStreams {
private LoggerStreams(final Logger logger) {
if (!(logger instanceof ExtendedLogger)) {
- throw new IncompatibleLoggerException(logger);
+ throw new UnsupportedOperationException("The provided Logger [" + String.valueOf(logger) +
+ "] does not implement " + ExtendedLogger.class.getName());
}
this.logger = (ExtendedLogger) logger;
}