Sha256: 594c909be66c6c93172555a5ad171d09287d03e5d5a12197ddd2565f679c9672

Contents?: true

Size: 1.76 KB

Versions: 154

Compression:

Stored size: 1.76 KB

Contents

package erratum

import "io"

// These are the support types and interface definitions used in the
// implementation if your Use function. See the test suite file at
// for information on the expected implementation.
//
// Because this is part of the package "erratum", if your solution file
// is also declared in the package you will automatically have access to
// these definitions (you do not have to re-declare them).

// TransientError is an error that may occur while opening a resource via
// ResourceOpener.
type TransientError struct {
	err error
}

func (e TransientError) Error() string {
	return e.err.Error()
}

// FrobError is a possible error from doing some frobbing, your implementation
// will require calling your Resource's Defrob(string) method.
// When this error occurs, the FrobError's defrobTag string will contain the
// string you must pass into Defrob.
type FrobError struct {
	defrobTag string
	inner     error
}

func (e FrobError) Error() string {
	return e.inner.Error()
}

type Resource interface {

	// Resource is using composition to inherit the requirements of the io.Closer
	// interface. What this means is that a Resource implementation will be
	// expected to have a .Close() method too.
	io.Closer

	// Frob does something with the input string.
	// Because this is an incredibly badly designed system if there is an error
	// it panics.
	//
	// The panicked error may be a FrobError in which case Defrob should be
	// called with the .defrobTag string property of the error.
	Frob(string)

	Defrob(string)
}

// ResourceOpener is a function that creates a resource.
//
// It may return a wrapped error of type TransientError. In this case the resource
// is temporarily unavailable and the caller should retry soon.
type ResourceOpener func() (Resource, error)

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.179 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.178 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.177 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.176 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.175 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.174 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.173 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.172 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.171 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.170 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.169 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.167 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.166 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.165 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.164 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.163 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.162 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.161 tracks/go/exercises/error-handling/common.go
trackler-2.2.1.160 tracks/go/exercises/error-handling/common.go