001// Copyright 2006, 2008 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.ioc.internal.services;
016
017import org.apache.tapestry5.ioc.internal.util.InternalUtils;
018import org.apache.tapestry5.ioc.services.ExceptionInfo;
019
020import static java.util.Collections.unmodifiableList;
021import java.util.List;
022import java.util.Map;
023
024public class ExceptionInfoImpl implements ExceptionInfo
025{
026    private final String className;
027
028    private final String message;
029
030    private final Map<String, Object> properties;
031
032    private final List<StackTraceElement> stackTrace;
033
034    public ExceptionInfoImpl(Throwable t, Map<String, Object> properties, List<StackTraceElement> stackTrace)
035    {
036        className = t.getClass().getName();
037        message = t.getMessage() != null ? t.getMessage() : "";
038
039        this.properties = properties;
040        this.stackTrace = unmodifiableList(stackTrace);
041    }
042
043    @Override
044    public String getClassName()
045    {
046        return className;
047    }
048
049    @Override
050    public String getMessage()
051    {
052        return message;
053    }
054
055    @Override
056    public Object getProperty(String name)
057    {
058        return properties.get(name);
059    }
060
061    @Override
062    public List<String> getPropertyNames()
063    {
064        return InternalUtils.sortedKeys(properties);
065    }
066
067    @Override
068    public List<StackTraceElement> getStackTrace()
069    {
070        return stackTrace;
071    }
072
073}