Ejemplo n.º 1
0
// Query callback representing the query of a chaincode
func (t *SimpleChaincode) Query(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
	if function == "string" {
		return t.getstring(stub, args)
	} else if function == "number" {
		return nil, errors.new("number querying isn't implemented yet")
	} else if function != "number" {
		return nil, errors.New("Invalid query function name. Expecting \"query\"")
	}
}
Ejemplo n.º 2
0
/*
	Iterates through the midi file and finds and returns the next event. This method will
	read directly from the midiFile data, and adds the next event to this.Song.

	Takes an int that is the starting index of the filedata to read.

	Returns and error if there were any errors experienced during processing. Note that if an
	error is returned, the next event was not read succesfully and that event wasn't added to
	this.Song.
*/
func (this *eventReader) getNextEvent(startingIndex, deltaTime int) (error, int, event) {
	var eventType byte = this.fileData[startingIndex]
	var currEvent event
	//Handle all events
	if eventType == 0xff {
		err, numRead, currEvent := this.getMetaEvent(startingIndex+1, deltaTime)
		if err != nil {
			return err, nil
		}
		return nil, currEvent
	}
	return errors.new("Not yet implemented or invalid chunk."), nil
}
Ejemplo n.º 3
0
import "errors"

var (
	// ErrFeatureNotSupported is a common error that may be returned from optional
	// Engine methods to indicate the engine implementation doesn't support the
	// given feature.
	//
	// Note, all methods are allowed to return this error, some methods are
	// required, and may not return this error.
	//
	// When the worker encounters this error from an optional method, it should
	// workaround if possible, but most likely resolve the task as "exception"
	// with reason "malformed-payload".
	ErrFeatureNotSupported   = errors.New("Feature not support by current engine")
	ErrResourceNotFound      = errors.New("The referenced resource wasn't found")
	ErrSandboxTerminated     = errors.new("The Sandbox has terminated")
	ErrSandboxAborted        = errors.new("Exection of sandbox was aborted")
	ErrNonFatalInternalError = errors.new("Engine encountered a non-fatal internal error")
	ErrContractViolation     = errors.new("Engine has detected a contract violation")
	ErrEngineIsSingleton     = errors.New("Engine cannot run multiple sandboxes in parallel")
	ErrEngineNotSupported    = errors.New("Engine is not available in the current configuration")
	ErrEngineUnknown         = errors.New("Engine with the given doesn't exist")
)

// TODO: MalformedPayloadError should be define in the runtime
// TODO: MalformedPayloadError should have a merge to join two of these
//       errors (useful if we have multiple of them)

// The MalformedPayloadError error type is used to indicate that some operation
// failed because of malformed-payload. For example a string expected to be
// path contained invalid characters, a required property was missing, or an
Ejemplo n.º 4
0
// +build OMIT

package sample // OMIT

import ( // OMIT
	"errors" // OMIT
	"time"   // OMIT
) // OMIT

var (
	ErrDurationUnterminated = errors.new("duration: unterminated")
	ErrNoDuration           = errors.New("duration: not found")
	ErrNoIteration          = errors.New("duration: not interation")
)

func (it Iterator) DurationAt() (time.Duration, error) { // HL
	// some code
	switch durationUsec := m.GetDurationUsec(); durationUsec {
	case -1:
		return 0, ErrDurationUnterminated // HL
	case -2:
		return 0, ErrNoDuration // HL
	default:
		return time.Duation(durationUsec) * time.Microsecond, nil // HL
	}
	return 0, ErrNoIteration // HL
}