github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/api/models/synchronization/problem.go (about)

     1  package synchronization
     2  
     3  import (
     4  	"github.com/mutagen-io/mutagen/pkg/synchronization/core"
     5  )
     6  
     7  // Problem represents a synchronization problem.
     8  type Problem struct {
     9  	// Path is the path at which the problem occurred, relative to the
    10  	// synchronization root.
    11  	Path string `json:"path"`
    12  	// Error is a human-readable summary of the problem.
    13  	Error string `json:"error"`
    14  }
    15  
    16  // loadFromInternal sets a problem to match an internal Protocol Buffers
    17  // representation. The problem must be valid.
    18  func (p *Problem) loadFromInternal(problem *core.Problem) {
    19  	p.Path = problem.Path
    20  	p.Error = problem.Error
    21  }
    22  
    23  // exportProblems is a convenience function that calls Problem.loadFromInternal
    24  // for a slice of problems.
    25  func exportProblems(problems []*core.Problem) []Problem {
    26  	// If there are no problems, then just return a nil slice.
    27  	count := len(problems)
    28  	if count == 0 {
    29  		return nil
    30  	}
    31  
    32  	// Create the resulting slice.
    33  	results := make([]Problem, count)
    34  	for i := 0; i < count; i++ {
    35  		results[i].loadFromInternal(problems[i])
    36  	}
    37  
    38  	// Done.
    39  	return results
    40  }