Skip to content

Commit ac59456

Browse files
committed
fix: add error code no such process
This error code will be returned when trying to stop a non-existing checksum hash. Longhorn 10563 Signed-off-by: Shuo Wu <shuo.wu@suse.com>
1 parent b97c02b commit ac59456

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

pkg/jsonrpc/types.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ type RespErrorMsg string
2727
type RespErrorCode int32
2828

2929
const (
30-
RespErrorCodeNoFileExists = -17
31-
RespErrorCodeNoSuchDevice = -19
30+
RespErrorCodeNoSuchProcess = -3
31+
RespErrorCodeNoFileExists = -17
32+
RespErrorCodeNoSuchDevice = -19
3233
)
3334

3435
type Response struct {
@@ -59,6 +60,19 @@ func (re JSONClientError) Error() string {
5960
re.ID, re.Method, re.Params, re.ErrorDetail)
6061
}
6162

63+
func IsJSONRPCRespErrorNoSuchProcess(err error) bool {
64+
jsonRPCError, ok := err.(JSONClientError)
65+
if !ok {
66+
return false
67+
}
68+
responseError, ok := jsonRPCError.ErrorDetail.(*ResponseError)
69+
if !ok {
70+
return false
71+
}
72+
73+
return responseError.Code == RespErrorCodeNoSuchProcess
74+
}
75+
6276
func IsJSONRPCRespErrorNoSuchDevice(err error) bool {
6377
jsonRPCError, ok := err.(JSONClientError)
6478
if !ok {

0 commit comments

Comments
 (0)