001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.jsonrpc;
018
019import org.apache.juneau.marshall.*;
020
021/**
022 * JSON-RPC 2.0 error object.
023 */
024@Marshalled
025public class JsonRpcError {
026
027   private int code;
028   private String message;
029   private Object data;
030
031   /**
032    * Error code.
033    *
034    * @return The code.
035    */
036   public int getCode() {
037      return code;
038   }
039
040   /**
041    * Sets the error code.
042    *
043    * @param value The new value.
044    * @return This object (for method chaining).
045    */
046   public JsonRpcError setCode(int value) {
047      code = value;
048      return this;
049   }
050
051   /**
052    * Error message.
053    *
054    * @return The message, or {@code null} if not set.
055    */
056   public String getMessage() {
057      return message;
058   }
059
060   /**
061    * Sets the error message.
062    *
063    * @param value The new value.  Can be <jk>null</jk> to unset the property.
064    * @return This object (for method chaining).
065    */
066   public JsonRpcError setMessage(String value) {
067      message = value;
068      return this;
069   }
070
071   /**
072    * Optional structured error data.
073    *
074    * @return The data, or {@code null} if not set.
075    */
076   public Object getData() {
077      return data;
078   }
079
080   /**
081    * Sets optional structured error data.
082    *
083    * @param value The new value.  Can be <jk>null</jk> to unset the property.
084    * @return This object (for method chaining).
085    */
086   public JsonRpcError setData(Object value) {
087      data = value;
088      return this;
089   }
090}