Load is like [Get] but returns an error if the key is not found or if the state represents an error.
(key string)
| 112 | // Load is like [Get] but returns an error if the key is not found or if |
| 113 | // the state represents an error. |
| 114 | func (s *ShellStateStore) Load(key string) (*ShellState, error) { |
| 115 | if key == "" { |
| 116 | return nil, nil |
| 117 | } |
| 118 | st, exists := s.Get(key) |
| 119 | if !exists { |
| 120 | return nil, fmt.Errorf("tried to access non-existent state %q", key) |
| 121 | } |
| 122 | cp := st |
| 123 | cp.Calls = slices.Clone(st.Calls) |
| 124 | return &cp, cp.Error |
| 125 | } |
| 126 | |
| 127 | // Extract is like [Load] but also deletes the state from memory. |
| 128 | // |