// returns os.ErrNotExist when scan was not found
197800
func (h *handler) fetchScanFunc(br blob.Ref, searchFunc func(blob.Ref) (*search.SearchResult, error)) (mediaObject, error) {
	var mo mediaObject
	res, err := searchFunc(br)
	if err != nil {
		return mo, err
	}
	if len(res.Blobs) != 1 {
		return mo, os.ErrNotExist
	}
	if res.Describe == nil || len(res.Describe.Meta) == 0 {
		return mo, errors.New("scan permanode was not described")
	}
	for _, des := range res.Describe.Meta {
		if des.Permanode == nil {
			continue
		}
		scan, err := h.describeScan(des)
		if err != nil {
			return mo, fmt.Errorf("error describing scan %v: %v", des.BlobRef, err)
		}
		return scan, nil
	}
	return mo, os.ErrNotExist
}
139825
func transformStartContainerError(err error) error {
	if err == nil {
		return nil
	}
	matches := startRE.FindStringSubmatch(err.Error())
	if len(matches) > 0 {
		return fmt.Errorf("executable not found in $PATH")
	}
	return err
}
849099
func (s *String) Scan(value interface{}) error {
	if value == nil {
		s.Chars, s.Valid = "", false
		return nil
	}
	s.Valid = true

	switch v := value.(type) {
	case []byte:
		s.Chars = string(v)
	case string:
		s.Chars = v
	default:
		return fmt.Errorf("ntypes: unsuported type (%T) passed to String.Scan", value)
	}

	return nil
}
87016
func (s *state) errRecover(errp *error) {
	if e := recover(); e != nil {
		switch e := e.(type) {
		case runtime.Error:
			*errp = s.errFromNode("%s: %v\n%v", s.callAnnotation(), e, string(debug.Stack()))
		default:
			*errp = s.errFromNode("%s: %v", s.callAnnotation(), e)
		}
	}
}
1300562
func (s *Scanner) error(c int, context string) int {
	s.Step = stateError
	s.Err = &SyntaxError{"invalid character " + quoteChar(c) + " " + context, s.bytes}
	return ScanError
}
213220
func (n *NullInt32) Scan(value interface{}) (err error) {
	if value == nil {
		n.Int32, n.Valid = 0, false
		return
	}

	switch v := value.(type) {
	case int64:
		n.Int32, n.Valid = int32(v), true
		return
	case []uint8:
		if i, e := strconv.ParseInt(string(v), 10, 32); e == nil {
			n.Int32, n.Valid = int32(i), true
		}
		return
	}

	n.Valid = false
	return fmt.Errorf("null: can't convert %T to int32", value)
}
1331618
func NewErrorExitError(message string, err error) error {
	if wordRegex.MatchString(message[len(message)-1:]) {
		message += "."
	}
	return cli.NewExitError(message+"\n"+err.Error(), -1)
}
39555
func (e ErrUnknownHtlcIndex) Error() string {
	return fmt.Sprintf("No HTLC with ID %d in channel %v",
		e.index, e.chanID)
}
931827
func (dst *Lseg) Scan(src interface{}) error {
	if src == nil {
		*dst = Lseg{Status: Null}
		return nil
	}

	switch src := src.(type) {
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		srcCopy := make([]byte, len(src))
		copy(srcCopy, src)
		return dst.DecodeText(nil, srcCopy)
	}

	return errors.Errorf("cannot scan %T", src)
}
794235
func (a *BoolArray) Scan(src interface{}) error {
	switch src := src.(type) {
	case []byte:
		return a.scanBytes(src)
	case string:
		return a.scanBytes([]byte(src))
	case nil:
		*a = nil
		return nil
	}

	return fmt.Errorf("pq: cannot convert %T to BoolArray", src)
}
1089370
func sprintError(err error) string {
	makeRel := func(name string) string {
		if relname, err := filepath.Rel(currentDirectory, name); err == nil {
			return relname
		}
		return name
	}

	switch e := err.(type) {
	case *scanner.Error:
		return fmt.Sprintf("%s:%d:%d: %s", makeRel(e.Pos.Filename), e.Pos.Line, e.Pos.Column, e.Msg)
	case types.Error:
		pos := e.Fset.Position(e.Pos)
		return fmt.Sprintf("%s:%d:%d: %s", makeRel(pos.Filename), pos.Line, pos.Column, e.Msg)
	default:
		return fmt.Sprintf("%s", e)
	}
}
263831
func IsErrNotFound(err error) bool {
	return err != nil && strings.Contains(err.Error(), errNotFound)
}
911059
func (f *segmentTermsEnumFrame) scanToTermNonLeaf(target []byte,
	exactOnly bool) (status SeekStatus, err error) {

	fmt.Printf(
		"    scanToTermNonLeaf: block fp=%v prefix=%v nextEnt=%v (of %v) target=%v term=%v",
		f.fp, f.prefix, f.nextEnt, f.entCount, brToString(target), "" /*brToString(term)*/)

	assert(f.nextEnt != -1)

	if f.nextEnt == f.entCount {
		panic("not implemented yet")
	}

	assert(f.prefixMatches(target))

	// Loop over each entry (term or sub-block) in this block:
	for {
		f.nextEnt++

		code, _ := f.suffixesReader.ReadVInt() // no error
		f.suffix = int(uint32(code) >> 1)

		f.ste.termExists = (code & 1) == 0
		termLen := f.prefix + f.suffix
		f.startBytePos = f.suffixesReader.Position()
		f.suffixesReader.SkipBytes(int64(f.suffix))
		if f.ste.termExists {
			f.state.TermBlockOrd++
			f.subCode = 0
		} else {
			f.subCode, _ = f.suffixesReader.ReadVLong() // no error
			f.lastSubFP = f.fp - f.subCode
		}

		targetLimit := termLen
		if len(target) < termLen {
			targetLimit = len(target)
		}
		targetPos := f.prefix

		// Loop over bytes in the suffix, comparing to the target
		bytePos := f.startBytePos
		var toNextTerm, stopScan bool
		for {
			var cmp int
			var stop bool
			if targetPos < targetLimit {
				cmp = int(f.suffixBytes[bytePos]) - int(target[targetPos])
				bytePos++
				targetPos++
				stop = false
			} else {
				assert(targetPos == targetLimit)
				cmp = termLen - len(target)
				stop = true
			}

			if cmp < 0 {
				// Current entry is still before the target;
				// keep scanning

				if f.nextEnt == f.entCount {
					if exactOnly {
						f.fillTerm()
					}
					// We are done scanning this block
					stopScan = true
					break
				} else {
					toNextTerm = true
					break
				}
			} else if cmp > 0 {
				// Done! Current entry is after target -- return NOT_FOUND:
				f.fillTerm()

				if !exactOnly && !f.ste.termExists {
					panic("niy")
				}

				fmt.Println("        not found")
				return SEEK_STATUS_NOT_FOUND, nil
			} else if stop {
				// Exact match!

				// This cannot be a sub-block because we would have followed
				// the index to this sub-block from the start:

				assert(f.ste.termExists)
				f.fillTerm()
				fmt.Println("        found!")
				return SEEK_STATUS_FOUND, nil
			}
		}
		if toNextTerm {
			continue
		}
		if stopScan {
			break
		}
	}

	// It is possible (and OK) that terms index pointed us at this
	// block, but, we scanned the entire block and did not find the
	// term to position to. This happens when the taret is after the
	// last term in the block (but, before the next term in the index).
	// E.g., target could be foozzz, and terms index pointed us to the
	// foo* block, but the last term in this block was fooz (and, e.g.,
	// first term in the next block will be fop).
	fmt.Println("      block end")
	if exactOnly {
		f.fillTerm()
	}

	return SEEK_STATUS_END, nil
}
47969
func doRecover(errp *error) {
	e := recover()
	if e != nil {
		if _, ok := e.(runtime.Error); ok {
			panic(e)
		}
		if err, ok := e.(error); ok {
			*errp = err
		} else if errStr, ok := e.(string); ok {
			*errp = errors.New(errStr)
		} else {
			*errp = fmt.Errorf("%v", e)
		}
	}
	return
}
612118
func (e WrongOpsError) Error() string {
	return fmt.Sprintf("Ops for folder %v, branch %s, was given path %s, "+
		"branch %s", e.opsFB.Tlf, e.opsFB.Branch, e.nodeFB.Tlf, e.nodeFB.Branch)
}
263788
func (n *NetID) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return errors.New("lorawan: []byte type expected")
	}
	if len(b) != len(n) {
		return fmt.Errorf("lorawan: []byte must have length %d", len(n))
	}
	copy(n[:], b)
	return nil
}
134459
func (v *KeyValue_GetValue_Result) GetDoesNotExist() (o *ResourceDoesNotExist) {
	if v != nil && v.DoesNotExist != nil {
		return v.DoesNotExist
	}

	return
}