2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core;
11 import java.util.Arrays;
13 import org.opendaylight.openflowplugin.ConnectionException;
14 import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
15 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * dumping all exceptions to log
23 public class ErrorHandlerSimpleImpl implements ErrorHandler {
25 private static final Logger LOG = LoggerFactory
26 .getLogger(ErrorHandlerSimpleImpl.class);
29 public void handleException(Throwable e, SessionContext sessionContext) {
30 String sessionKeyId = null;
31 if (sessionContext != null) {
32 sessionKeyId = Arrays.toString(sessionContext.getSessionKey().getId());
35 if (e instanceof ConnectionException) {
36 LOG.warn("exception -> {}, session -> {}", e.getMessage(), sessionKeyId, e);
38 LOG.error("exception -> {}, session -> {}", e.getMessage(), sessionKeyId, e);