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 55 56 57 58 59 60 61 62 63
|
// Tideland Go Library - Simple Markup Language - Errors
//
// Copyright (C) 2009-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
package sml
//--------------------
// IMPORTS
//--------------------
import (
"github.com/tideland/golib/errors"
)
//--------------------
// CONSTANTS
//--------------------
// Error codes of the SML package.
const (
ErrBuilder = iota + 1
ErrReader
ErrNoRootProcessor
ErrRegisteredPlugin
)
var errorMessages = errors.Messages{
ErrBuilder: "cannot build node structure: %v",
ErrReader: "cannot read SML document: %v",
ErrNoRootProcessor: "no root processor registered",
ErrRegisteredPlugin: "plugin processor with tag %q is already registered",
}
//--------------------
// ERROR
//--------------------
// IsBuilderError checks for an error during node building.
func IsBuilderError(err error) bool {
return errors.IsError(err, ErrBuilder)
}
// IsReaderError checks for an error during SML text reading.
func IsReaderError(err error) bool {
return errors.IsError(err, ErrBuilder)
}
// IsNoRootProcessorError checks for an unregistered root
// processor.
func IsNoRootProcessorError(err error) bool {
return errors.IsError(err, ErrNoRootProcessor)
}
// IsRegisteredPluginError checks for the error of an already
// registered plugin.
func IsRegisteredPluginError(err error) bool {
return errors.IsError(err, ErrRegisteredPlugin)
}
// EOF
|