go.uber.org/cadence@v1.2.9/internal/compatibility/testdata/error.go (about)

     1  // Copyright (c) 2021 Uber Technologies Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in all
    11  // copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    19  // SOFTWARE.
    20  
    21  package testdata
    22  
    23  import (
    24  	"go.uber.org/yarpc/encoding/protobuf"
    25  	"go.uber.org/yarpc/yarpcerrors"
    26  
    27  	apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
    28  )
    29  
    30  const (
    31  	ErrorMessage = "ErrorMessage"
    32  	FeatureFlag  = "FeatureFlag"
    33  )
    34  
    35  var (
    36  	AccessDeniedError                 = protobuf.NewError(yarpcerrors.CodePermissionDenied, ErrorMessage)
    37  	BadRequestError                   = protobuf.NewError(yarpcerrors.CodeInvalidArgument, ErrorMessage)
    38  	CancellationAlreadyRequestedError = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.CancellationAlreadyRequestedError{}))
    39  	ClientVersionNotSupportedError    = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Client version not supported", protobuf.WithErrorDetails(&apiv1.ClientVersionNotSupportedError{
    40  		FeatureVersion:    FeatureVersion,
    41  		ClientImpl:        ClientImpl,
    42  		SupportedVersions: SupportedVersions,
    43  	}))
    44  	DomainAlreadyExistsError = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.DomainAlreadyExistsError{}))
    45  	DomainNotActiveError     = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, ErrorMessage, protobuf.WithErrorDetails(&apiv1.DomainNotActiveError{
    46  		Domain:         DomainName,
    47  		CurrentCluster: ClusterName1,
    48  		ActiveCluster:  ClusterName2,
    49  	}))
    50  	EntityNotExistsError = protobuf.NewError(yarpcerrors.CodeNotFound, ErrorMessage, protobuf.WithErrorDetails(&apiv1.EntityNotExistsError{
    51  		CurrentCluster: ClusterName1,
    52  		ActiveCluster:  ClusterName2,
    53  	}))
    54  	FeatureNotEnabledError = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Feature flag not enabled", protobuf.WithErrorDetails(&apiv1.FeatureNotEnabledError{
    55  		FeatureFlag: FeatureFlag,
    56  	}))
    57  	WorkflowExecutionAlreadyCompletedError = protobuf.NewError(yarpcerrors.CodeNotFound, ErrorMessage, protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyCompletedError{}))
    58  	InternalServiceError                   = protobuf.NewError(yarpcerrors.CodeInternal, ErrorMessage)
    59  	LimitExceededError                     = protobuf.NewError(yarpcerrors.CodeResourceExhausted, ErrorMessage, protobuf.WithErrorDetails(&apiv1.LimitExceededError{}))
    60  	QueryFailedError                       = protobuf.NewError(yarpcerrors.CodeInvalidArgument, ErrorMessage, protobuf.WithErrorDetails(&apiv1.QueryFailedError{}))
    61  	ServiceBusyError                       = protobuf.NewError(yarpcerrors.CodeResourceExhausted, ErrorMessage, protobuf.WithErrorDetails(&apiv1.ServiceBusyError{}))
    62  	WorkflowExecutionAlreadyStartedError   = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyStartedError{
    63  		StartRequestId: RequestID,
    64  		RunId:          RunID,
    65  	}))
    66  	UnknownError = protobuf.NewError(yarpcerrors.CodeUnknown, ErrorMessage)
    67  )