aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/util/operation_result.go
blob: 5e79f727d4e71241b7d890f037f05ec4b70e7804 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// A struct containing the result of an operation
// Author: bratseth

package util

type OperationResult struct {
	Success bool
	Message string // Mandatory message
	Detail  string // Optional detail message
	Payload string // Optional payload - may be present whether or not the operation was success
}

func Success(message string) OperationResult {
	return OperationResult{Success: true, Message: message}
}

func SuccessWithPayload(message string, payload string) OperationResult {
	return OperationResult{Success: true, Message: message, Payload: payload}
}

func Failure(message string) OperationResult {
	return OperationResult{Success: false, Message: message}
}

func FailureWithPayload(message string, payload string) OperationResult {
	return OperationResult{Success: false, Message: message, Payload: payload}
}

func FailureWithDetail(message string, detail string) OperationResult {
	return OperationResult{Success: false, Message: message, Detail: detail}
}