gitlab.com/evatix-go/core@v1.3.55/chmodhelper/chmodins/ParseRwxInstructionUsingJsonResult.go (about)

     1  package chmodins
     2  
     3  import (
     4  	"gitlab.com/evatix-go/core/coredata/corejson"
     5  	"gitlab.com/evatix-go/core/errcore"
     6  )
     7  
     8  func ParseRwxInstructionUsingJsonResult(
     9  	result *corejson.Result,
    10  ) (*RwxInstruction, error) {
    11  	if result == nil {
    12  		return nil,
    13  			errcore.BytesAreNilOrEmptyType.Error(
    14  				"ParseRwxInstructionUsingJsonResult", nil)
    15  	}
    16  
    17  	if result.IsEmptyJsonBytes() || result.HasError() {
    18  		return nil, result.MeaningfulError()
    19  	}
    20  
    21  	var rwxInstruction RwxInstruction
    22  	err := result.Unmarshal(&rwxInstruction)
    23  
    24  	if err != nil {
    25  		return nil, errcore.MeaningfulError(
    26  			errcore.FailedToParseType,
    27  			"ParseRwxInstructionUsingJsonResult",
    28  			err)
    29  	}
    30  
    31  	return &rwxInstruction, err
    32  }