/*
 * 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 com.facebook.presto.spi;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public final class ErrorCode
{
    private final int code;
    private final String name;

    @JsonCreator
    public ErrorCode(@JsonProperty("code") int code, @JsonProperty("name") String name)
    {
        this.code = code;
        this.name = name;
    }

    @JsonProperty
    public int getCode()
    {
        return code;
    }

    @JsonProperty
    public String getName()
    {
        return name;
    }
}

@@ -697,16 +697,65 @@
 perty;%0A%0A
+import static java.util.Objects.requireNonNull;%0A%0A
 public f
@@ -940,32 +940,134 @@
 ing name)%0A    %7B%0A
+        if (code %3C 0) %7B%0A            throw new IllegalArgumentException(%22code is negative%22);%0A        %7D%0A
         this.cod
@@ -1096,20 +1096,52 @@
 .name = 
-name
+requireNonNull(name, %22name is null%22)
 ;%0A    %7D%0A
@@ -1296,11 +1296,101 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return name + %22:%22 + code;%0A    %7D
 %0A%7D%0A

Add validation to ErrorCode