File: errors.go

package info (click to toggle)
golang-github-tideland-golib 4.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,144 kB
  • sloc: makefile: 4
file content (54 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Tideland Go Library - Atom Feed
//
// Copyright (C) 2012-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.

package atom

//--------------------
// IMPORTS
//--------------------

import (
	"github.com/tideland/golib/errors"
)

//--------------------
// CONSTANTS
//--------------------

// Error codes of the atom feed package.
const (
	ErrValidation = iota + 1
	ErrParsing
	ErrNoPlainText
)

var errorMessages = errors.Messages{
	ErrParsing:     "cannot parse %s",
	ErrNoPlainText: "cannot convert text element %q to plain text",
}

//--------------------
// ERROR CHECKING
//--------------------

// IsValidationError checks if the error signals an invalid feed.
func IsValidationError(err error) bool {
	return errors.IsError(err, ErrValidation)
}

// IsParsingError checks if the error signals a bad formatted value.
func IsParsingError(err error) bool {
	return errors.IsError(err, ErrParsing)
}

// IsNoPlainTextError checks if the error signals no plain content
// inside a text element.
func IsNoPlainTextError(err error) bool {
	return errors.IsError(err, ErrNoPlainText)
}

// EOF