this repo has no description
at master 50 lines 1.2 kB view raw
1// Copyright 2019 CUE Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package openapi 16 17import ( 18 "cuelang.org/go/cue" 19 "cuelang.org/go/cue/errors" 20 "cuelang.org/go/cue/token" 21) 22 23var _ errors.Error = &openapiError{} 24 25// implements cue/Error 26type openapiError struct { 27 errors.Message 28 path cue.Path 29 pos token.Pos 30} 31 32func (e *openapiError) Position() token.Pos { 33 return e.pos 34} 35 36func (e *openapiError) InputPositions() []token.Pos { 37 return nil 38} 39 40func (e *openapiError) Path() []string { 41 return pathToStrings(e.path) 42} 43 44// pathToString is a utility function for creating debugging info. 45func pathToStrings(p cue.Path) (a []string) { 46 for _, sel := range p.Selectors() { 47 a = append(a, sel.String()) 48 } 49 return a 50}