1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 // Abort aborts the thread's current computation,
14 // causing the innermost Try to return err.
15 func (t
*Thread
) Abort(err os
.Error
) {
17 panic("abort: " + err
.String())
23 // Try executes a computation; if the computation
24 // Aborts, Try returns the error passed to abort.
25 func (t
*Thread
) Try(f
func(t
*Thread
)) os
.Error
{
27 c
:= make(chan os
.Error
)
38 type DivByZeroError
struct{}
40 func (DivByZeroError
) String() string { return "divide by zero" }
42 type NilPointerError
struct{}
44 func (NilPointerError
) String() string { return "nil pointer dereference" }
46 type IndexError
struct {
50 func (e IndexError
) String() string {
52 return fmt
.Sprintf("negative index: %d", e
.Idx
)
54 return fmt
.Sprintf("index %d exceeds length %d", e
.Idx
, e
.Len
)
57 type SliceError
struct {
61 func (e SliceError
) String() string {
62 return fmt
.Sprintf("slice [%d:%d]; cap %d", e
.Lo
, e
.Hi
, e
.Cap
)
65 type KeyError
struct {
69 func (e KeyError
) String() string { return fmt
.Sprintf("key '%v' not found in map", e
.Key
) }
71 type NegativeLengthError
struct {
75 func (e NegativeLengthError
) String() string {
76 return fmt
.Sprintf("negative length: %d", e
.Len
)
79 type NegativeCapacityError
struct {
83 func (e NegativeCapacityError
) String() string {
84 return fmt
.Sprintf("negative capacity: %d", e
.Len
)