mirrored from https://chromium.googlesource.com/infra/luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy patherrors.py
54 lines (42 loc) · 1.71 KB
/
errors.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright 2022 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Exceptions for handling CIPD and CAS errors"""
class NonRecoverableException(Exception):
"""For handling errors where we cannot recover from and should not retry."""
def __init__(self, status, msg):
super(Exception, self).__init__(msg)
self.status = status
def to_dict(self):
"""Returns a dictionary with the attributes serialised."""
raise NotImplementedError()
class NonRecoverableCasException(NonRecoverableException):
"""For handling a bad CAS input where we should not attempt to retry."""
def __init__(self, status, digest, instance):
super(NonRecoverableCasException, self).__init__(
status, "CAS error: {} with digest {} on instance {}".format(
status, digest, instance))
self.digest = digest
self.instance = instance
def to_dict(self):
return {
'status': self.status,
'digest': self.digest,
'instance': self.instance,
}
class NonRecoverableCipdException(NonRecoverableException):
"""For handling a bad CIPD package where we should not attempt to retry."""
def __init__(self, status, package_name, path, version):
super(NonRecoverableCipdException, self).__init__(
status, "CIPD error: {} with package {}, version {} on path {}".format(
status, package_name, version, path))
self.package_name = package_name
self.path = path
self.version = version
def to_dict(self):
return {
'status': self.status,
'package_name': self.package_name,
'path': self.path,
'version': self.version
}