X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=common%2FrNibErrors.go;fp=common%2FrNibErrors.go;h=0000000000000000000000000000000000000000;hb=68a3eec5f7e3257141f8043f548608296a6737b1;hp=c5d6620acb5f88485ea4b9016c923289976c73b4;hpb=7c64c2f5afa77052fb1eb56c06f464e9e5673ff9;p=ric-plt%2Fnodeb-rnib.git diff --git a/common/rNibErrors.go b/common/rNibErrors.go deleted file mode 100644 index c5d6620..0000000 --- a/common/rNibErrors.go +++ /dev/null @@ -1,67 +0,0 @@ -// -// Copyright 2019 AT&T Intellectual Property -// Copyright 2019 Nokia -// -// 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 common - -import "fmt" - -const( - RESOURCE_NOT_FOUND int = 1 - INTERNAL_ERROR int = 2 - VALIDATION_ERROR int = 3 -) - -var rNibError_names = map[int]string{ - RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND", - INTERNAL_ERROR:"INTERNAL_ERROR", - VALIDATION_ERROR:"VALIDATION_ERROR", -} - -type IRNibError interface{ - error - GetCode() int - GetError() error -} - -type RNibError struct{ - err error - errorCode int -} - -func NewResourceNotFoundError(error error) IRNibError { - return IRNibError(&RNibError{err:error, errorCode:RESOURCE_NOT_FOUND}) -} - -func NewInternalError(error error) IRNibError { - return IRNibError(&RNibError{err:error, errorCode:INTERNAL_ERROR}) -} - -func NewValidationError(error error) IRNibError { - return IRNibError(&RNibError{err:error, errorCode:VALIDATION_ERROR}) -} - -func (e RNibError) GetError() error { - return e.err -} - -func (e RNibError) GetCode() int { - return e.errorCode -} - -func (e RNibError) Error() string { - return fmt.Sprintf("%d %s - %s", e.errorCode, rNibError_names[e.errorCode], e.err) -} \ No newline at end of file