org.glowroot.container.trace.ErrorMessage Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2013-2015 the original author or authors.
*
* 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 org.glowroot.container.trace;
import javax.annotation.Nullable;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.google.common.base.MoreObjects;
public class ErrorMessage {
private final @Nullable String message;
private final @Nullable ThrowableInfo throwable;
private ErrorMessage(@Nullable String message, @Nullable ThrowableInfo throwable) {
this.message = message;
this.throwable = throwable;
}
public @Nullable String getMessage() {
return message;
}
public @Nullable ThrowableInfo getThrowable() {
return throwable;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("message", message)
.add("throwable", throwable)
.toString();
}
@JsonCreator
static ErrorMessage readValue(
@JsonProperty("message") @Nullable String message,
@JsonProperty("throwable") @Nullable ThrowableInfo throwable)
throws JsonMappingException {
return new ErrorMessage(message, throwable);
}
}