aboutsummaryrefslogtreecommitdiffstats
path: root/moon_utilities/moon_utilities/exceptions.py
blob: 4e016e7074119f44f391ecdc240bae0ee7273f91 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
# Software Name: MOON

# Version: 5.4

# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0

# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LICENSE" file for more details.


import logging

logger = logging.getLogger("moon.utilities.exceptions")
_ = str


class MoonErrorMetaClass(type):

    def __init__(cls, name, bases, dct):
        super(MoonErrorMetaClass, cls).__init__(name, bases, dct)
        cls.hierarchy += "/" + str(name)


class MoonError(BaseException):
    __metaclass__ = MoonErrorMetaClass
    hierarchy = ""
    description = _("There is an error requesting the Moon platform.")
    code = 400
    title = 'Moon Error'
    logger = "ERROR"

    def __init__(self, message="", status_code=None, payload=""):
        if message:
            self.description = message
        if status_code:
            self.code = status_code
        self.payload = payload
        super(MoonError, self).__init__()

    def __str__(self):
        return "{}: {}".format(self.code, self.title)

    def __del__(self):
        message = "{} ({}) {}".format(self.hierarchy, self.description, self.payload)
        if self.logger == "ERROR":
            try:
                logger.error(message)
            except AttributeError:
                logger.error(message)
        elif self.logger == "WARNING":
            try:
                logger.warning(message)
            except AttributeError:
                logger.warning(message)
        elif self.logger == "CRITICAL":
            try:
                logger.critical(message)
            except AttributeError:
                logger.critical(message)
        elif self.logger == "AUTHZ":
            try:
                logger.error(message)
            except AttributeError:
                logger.error(message)
        else:
            try:
                logger.info(message)
            except AttributeError:
                logger.info(message)

    # def to_dict(self):
    #     rv = dict(self.payload or ())
    #     rv['message'] = "{} ({})".format(self.hierarchy, self.description)
    #     rv['title'] = self.title
    #     rv['code'] = self.code
    #     return rv


# Exceptions for Tenant

class TenantException(MoonError):
    description = _("There is an error requesting this tenant.")
    code = 400
    title = 'Tenant Error'
    logger = "ERROR"


class TenantUnknown(TenantException):
    description = _("The tenant is unknown.")
    code = 400
    title = 'Tenant Unknown'
    logger = "ERROR"


class TenantAddedNameExisting(TenantException):
    description = _("The tenant name is existing.")
    code = 400
    title = 'Added Tenant Name Existing'
    logger = "ERROR"


class TenantNoIntraExtension(TenantException):
    description = _("The tenant has not intra_extension.")
    code = 400
    title = 'Tenant No Intra_Extension'
    logger = "ERROR"


class TenantNoIntraAuthzExtension(TenantNoIntraExtension):
    description = _("The tenant has not intra_admin_extension.")
    code = 400
    title = 'Tenant No Intra_Admin_Extension'
    logger = "ERROR"


# Exceptions for IntraExtension


class IntraExtensionException(MoonError):
    description = _("There is an error requesting this IntraExtension.")
    code = 400
    title = 'Extension Error'


class IntraExtensionUnknown(IntraExtensionException):
    description = _("The intra_extension is unknown.")
    code = 400
    title = 'Intra Extension Unknown'
    logger = "Error"


class ModelUnknown(MoonError):
    description = _("The model is unknown.")
    code = 400
    title = 'Model Unknown'
    logger = "Error"


class ModelContentError(MoonError):
    description = _("The model content is invalid.")
    code = 400
    title = 'Model Unknown'
    logger = "Error"


class ModelExisting(MoonError):
    description = _("The model already exists.")
    code = 409
    title = 'Model Error'
    logger = "Error"


# Authz exceptions

class AuthzException(MoonError):
    description = _("There is an authorization error requesting this IntraExtension.")
    code = 403
    title = 'Authz Exception'
    logger = "AUTHZ"


# Auth exceptions

class AuthException(MoonError):
    description = _("There is an authentication error requesting this API. "
                    "You must provide a valid token from Keystone.")
    code = 401
    title = 'Auth Exception'
    logger = "AUTHZ"


# Admin exceptions

class AdminException(MoonError):
    description = _("There is an error requesting this Authz IntraExtension.")
    code = 400
    title = 'Authz Exception'
    logger = "AUTHZ"


class AdminMetaData(AdminException):
    code = 400
    title = 'Metadata Exception'


class AdminPerimeter(AdminException):
    code = 400
    title = 'Perimeter Exception'


class AdminScope(AdminException):
    code = 400
    title = 'Scope Exception'


class AdminAssignment(AdminException):
    code = 400
    title = 'Assignment Exception'


class AdminMetaRule(AdminException):
    code = 400
    title = 'Aggregation Algorithm Exception'


class AdminRule(AdminException):
    code = 400
    title = 'Rule Exception'


class CategoryNameInvalid(AdminMetaData):
    description = _("The given category name is invalid.")
    code = 400
    title = 'Category Name Invalid'
    logger = "ERROR"


class SubjectCategoryExisting(AdminMetaData):
    description = _("The given subject category already exists.")
    code = 409
    title = 'Subject Category Existing'
    logger = "ERROR"


class ObjectCategoryExisting(AdminMetaData):
    description = _("The given object category already exists.")
    code = 409
    title = 'Object Category Existing'
    logger = "ERROR"


class ActionCategoryExisting(AdminMetaData):
    description = _("The given action category already exists.")
    code = 409
    title = 'Action Category Existing'
    logger = "ERROR"


class SubjectCategoryUnknown(AdminMetaData):
    description = _("The given subject category is unknown.")
    code = 400
    title = 'Subject Category Unknown'
    logger = "ERROR"


class DeleteSubjectCategoryWithMetaRule(MoonError):
    description = _("Cannot delete subject category used in meta rule ")
    code = 400
    title = 'Subject Category With Meta Rule Error'
    logger = "Error"


class DeleteObjectCategoryWithMetaRule(MoonError):
    description = _("Cannot delete Object category used in meta rule ")
    code = 400
    title = 'Object Category With Meta Rule Error'
    logger = "Error"


class ObjectCategoryUnknown(AdminMetaData):
    description = _("The given object category is unknown.")
    code = 400
    title = 'Object Category Unknown'
    logger = "ERROR"


class DeleteActionCategoryWithMetaRule(MoonError):
    description = _("Cannot delete Action category used in meta rule ")
    code = 400
    title = 'Action Category With Meta Rule Error'
    logger = "Error"


class ActionCategoryUnknown(AdminMetaData):
    description = _("The given action category is unknown.")
    code = 400
    title = 'Action Category Unknown'
    logger = "ERROR"


class PerimeterContentError(AdminPerimeter):
    description = _("Perimeter content is invalid.")
    code = 400
    title = 'Perimeter content is invalid.'
    logger = "ERROR"


class DeletePerimeterWithAssignment(MoonError):
    description = _("Cannot delete perimeter with assignment")
    code = 400
    title = 'Perimeter With Assignment Error'
    logger = "Error"


class SubjectUnknown(AdminPerimeter):
    description = _("The given subject is unknown.")
    code = 400
    title = 'Subject Unknown'
    logger = "ERROR"


class ObjectUnknown(AdminPerimeter):
    description = _("The given object is unknown.")
    code = 400
    title = 'Object Unknown'
    logger = "ERROR"


class ActionUnknown(AdminPerimeter):
    description = _("The given action is unknown.")
    code = 400
    title = 'Action Unknown'
    logger = "ERROR"


class SubjectExisting(AdminPerimeter):
    description = _("The given subject is existing.")
    code = 409
    title = 'Subject Existing'
    logger = "ERROR"


class ObjectExisting(AdminPerimeter):
    description = _("The given object is existing.")
    code = 409
    title = 'Object Existing'
    logger = "ERROR"


class ActionExisting(AdminPerimeter):
    description = _("The given action is existing.")
    code = 409
    title = 'Action Existing'
    logger = "ERROR"


class SubjectNameExisting(AdminPerimeter):
    description = _("The given subject name is existing.")
    code = 409
    title = 'Subject Name Existing'
    logger = "ERROR"


class ObjectNameExisting(AdminPerimeter):
    description = _("The given object name is existing.")
    code = 409
    title = 'Object Name Existing'
    logger = "ERROR"


class ActionNameExisting(AdminPerimeter):
    description = _("The given action name is existing.")
    code = 409
    title = 'Action Name Existing'
    logger = "ERROR"


class ObjectsWriteNoAuthorized(AdminPerimeter):
    description = _("The modification on Objects is not authorized.")
    code = 400
    title = 'Objects Write No Authorized'
    logger = "AUTHZ"


class ActionsWriteNoAuthorized(AdminPerimeter):
    description = _("The modification on Actions is not authorized.")
    code = 400
    title = 'Actions Write No Authorized'
    logger = "AUTHZ"


class SubjectScopeUnknown(AdminScope):
    description = _("The given subject scope is unknown.")
    code = 400
    title = 'Subject Scope Unknown'
    logger = "ERROR"


class ObjectScopeUnknown(AdminScope):
    description = _("The given object scope is unknown.")
    code = 400
    title = 'Object Scope Unknown'
    logger = "ERROR"


class ActionScopeUnknown(AdminScope):
    description = _("The given action scope is unknown.")
    code = 400
    title = 'Action Scope Unknown'
    logger = "ERROR"


class SubjectScopeExisting(AdminScope):
    description = _("The given subject scope is existing.")
    code = 409
    title = 'Subject Scope Existing'
    logger = "ERROR"


class ObjectScopeExisting(AdminScope):
    description = _("The given object scope is existing.")
    code = 409
    title = 'Object Scope Existing'
    logger = "ERROR"


class ActionScopeExisting(AdminScope):
    description = _("The given action scope is existing.")
    code = 409
    title = 'Action Scope Existing'
    logger = "ERROR"


class SubjectScopeNameExisting(AdminScope):
    description = _("The given subject scope name is existing.")
    code = 409
    title = 'Subject Scope Name Existing'
    logger = "ERROR"


class ObjectScopeNameExisting(AdminScope):
    description = _("The given object scope name is existing.")
    code = 409
    title = 'Object Scope Name Existing'
    logger = "ERROR"


class ActionScopeNameExisting(AdminScope):
    description = _("The given action scope name is existing.")
    code = 409
    title = 'Action Scope Name Existing'
    logger = "ERROR"


class SubjectAssignmentUnknown(AdminAssignment):
    description = _("The given subject assignment value is unknown.")
    code = 400
    title = 'Subject Assignment Unknown'
    logger = "ERROR"


class ObjectAssignmentUnknown(AdminAssignment):
    description = _("The given object assignment value is unknown.")
    code = 400
    title = 'Object Assignment Unknown'
    logger = "ERROR"


class ActionAssignmentUnknown(AdminAssignment):
    description = _("The given action assignment value is unknown.")
    code = 400
    title = 'Action Assignment Unknown'
    logger = "ERROR"


class SubjectAssignmentExisting(AdminAssignment):
    description = _("The given subject assignment value is existing.")
    code = 409
    title = 'Subject Assignment Existing'
    logger = "ERROR"


class ObjectAssignmentExisting(AdminAssignment):
    description = _("The given object assignment value is existing.")
    code = 409
    title = 'Object Assignment Existing'
    logger = "ERROR"


class ActionAssignmentExisting(AdminAssignment):
    description = _("The given action assignment value is existing.")
    code = 409
    title = 'Action Assignment Existing'
    logger = "ERROR"


class AggregationAlgorithmNotExisting(AdminMetaRule):
    description = _("The given aggregation algorithm is not existing.")
    code = 400
    title = 'Aggregation Algorithm Not Existing'
    logger = "ERROR"


class AggregationAlgorithmUnknown(AdminMetaRule):
    description = _("The given aggregation algorithm is unknown.")
    code = 400
    title = 'Aggregation Algorithm Unknown'
    logger = "ERROR"


class SubMetaRuleAlgorithmNotExisting(AdminMetaRule):
    description = _("The given sub_meta_rule algorithm is unknown.")
    code = 400
    title = 'Sub_meta_rule Algorithm Unknown'
    logger = "ERROR"


class MetaRuleUnknown(AdminMetaRule):
    description = _("The given meta rule is unknown.")
    code = 400
    title = 'Meta Rule Unknown'
    logger = "ERROR"


class MetaRuleNotLinkedWithPolicyModel(MoonError):
    description = _("The meta rule is not found in the model attached to the policy.")
    code = 400
    title = 'MetaRule Not Linked With Model - Policy'
    logger = "Error"


class CategoryNotAssignedMetaRule(MoonError):
    description = _("The category is not found in the meta rules attached to the policy.")
    code = 400
    title = 'Category Not Linked With Meta Rule - Policy'
    logger = "Error"


class SubMetaRuleNameExisting(AdminMetaRule):
    description = _("The sub meta rule name already exists.")
    code = 409
    title = 'Sub Meta Rule Name Existing'
    logger = "ERROR"


class MetaRuleExisting(AdminMetaRule):
    description = _("The meta rule already exists.")
    code = 409
    title = 'Meta Rule Existing'
    logger = "ERROR"


class MetaRuleContentError(AdminMetaRule):
    description = _("Invalid content of meta rule.")
    code = 400
    title = 'Meta Rule Error'
    logger = "ERROR"


class MetaRuleUpdateError(AdminMetaRule):
    description = _("Meta_rule is used in Rule.")
    code = 400
    title = 'Meta_Rule Update Error'
    logger = "ERROR"


class RuleExisting(AdminRule):
    description = _("The rule already exists.")
    code = 409
    title = 'Rule Existing'
    logger = "ERROR"


class RuleContentError(AdminRule):
    description = _("Invalid content of rule.")
    code = 400
    title = 'Rule Error'
    logger = "ERROR"


class RuleUnknown(AdminRule):
    description = _("The rule for that request doesn't exist.")
    code = 400
    title = 'Rule Unknown'
    logger = "ERROR"


# Consul exceptions


class ConsulError(MoonError):
    description = _("There is an error connecting to Consul.")
    code = 400
    title = 'Consul error'
    logger = "ERROR"


class ConsulComponentNotFound(ConsulError):
    description = _("The component do not exist in Consul database.")
    code = 500
    title = 'Consul error'
    logger = "WARNING"


class ConsulComponentContentError(ConsulError):
    description = _("invalid content of component .")
    code = 500
    title = 'Consul Content error'
    logger = "WARNING"


# Containers exceptions


class DockerError(MoonError):
    description = _("There is an error with Docker.")
    code = 400
    title = 'Docker error'
    logger = "ERROR"


class ContainerMissing(DockerError):
    description = _("Some containers are missing.")
    code = 400
    title = 'Container missing'
    logger = "ERROR"


class WrapperConflict(MoonError):
    description = _("A Wrapper already exist for the specified slave.")
    code = 409
    title = 'Wrapper conflict'
    logger = "ERROR"


class PipelineConflict(MoonError):
    description = _("A Pipeline already exist for the specified slave.")
    code = 409
    title = 'Pipeline conflict'
    logger = "ERROR"


class PipelineUnknown(MoonError):
    description = _("This Pipeline is unknown from the system.")
    code = 400
    title = 'Pipeline Unknown'
    logger = "ERROR"


class WrapperUnknown(MoonError):
    description = _("This Wrapper is unknown from the system.")
    code = 400
    title = 'Wrapper Unknown'
    logger = "ERROR"


class SlaveNameUnknown(MoonError):
    description = _("The slave is unknown.")
    code = 400
    title = 'Slave Unknown'
    logger = "Error"


class SlaveExisting(MoonError):
    description = _("The slave already exists.")
    code = 409
    title = 'Slave Error'
    logger = "Error"


class PdpUnknown(MoonError):
    description = _("The pdp is unknown.")
    code = 400
    title = 'Pdp Unknown'
    logger = "Error"


class PdpExisting(MoonError):
    description = _("The pdp already exists.")
    code = 409
    title = 'Pdp Error'
    logger = "Error"


class PdpContentError(MoonError):
    description = _("Invalid content of pdp.")
    code = 400
    title = 'Pdp Error'
    logger = "Error"


class PdpInUse(MoonError):
    description = _("The pdp is inuse.")
    code = 400
    title = 'Pdp Inuse'
    logger = "Error"


class PdpKeystoneMappingConflict(MoonError):
    description = _("A pdp is already mapped to that Keystone project.")
    code = 409
    title = 'Pdp Mapping Error'
    logger = "Error"


class PolicyUnknown(MoonError):
    description = _("The policy is unknown.")
    code = 400
    title = 'Policy Unknown'
    logger = "Error"


class PolicyContentError(MoonError):
    description = _("The policy content is invalid.")
    code = 400
    title = 'Policy Content Error'
    logger = "Error"


class PolicyExisting(MoonError):
    description = _("The policy already exists.")
    code = 409
    title = 'Policy Already Exists'
    logger = "Error"


class PolicyUpdateError(MoonError):
    description = _("The policy data is used.")
    code = 400
    title = 'Policy update error'
    logger = "Error"


class DeleteData(MoonError):
    description = _("Cannot delete data with assignment")
    code = 400
    title = 'Data Error'
    logger = "Error"


class DeleteCategoryWithData(MoonError):
    description = _("Cannot delete category with data")
    code = 400
    title = 'Category With Data Error'
    logger = "Error"


class DeleteCategoryWithMetaRule(MoonError):
    description = _("Cannot delete category with meta rule")
    code = 400
    title = 'Category With MetaRule Error'
    logger = "Error"


class DeleteCategoryWithAssignment(MoonError):
    description = _("Cannot delete category with assignment ")
    code = 400
    title = 'Category With Assignment Error'
    logger = "Error"


class DeleteModelWithPolicy(MoonError):
    description = _("Cannot delete model with policy")
    code = 400
    title = 'Model With Policy Error'
    logger = "Error"


class DeletePolicyWithPdp(MoonError):
    description = _("Cannot delete policy with pdp")
    code = 400
    title = 'Policy With PDP Error'
    logger = "Error"


class DeletePolicyWithPerimeter(MoonError):
    description = _("Cannot delete policy with perimeter")
    code = 400
    title = 'Policy With Perimeter Error'
    logger = "Error"


class DeletePolicyWithData(MoonError):
    description = _("Cannot delete policy with data")
    code = 400
    title = 'Policy With Data Error'
    logger = "Error"


class DeletePolicyWithRules(MoonError):
    description = _("Cannot delete policy with rules")
    code = 400
    title = 'Policy With Rule Error'
    logger = "Error"


class DeleteMetaRuleWithModel(MoonError):
    description = _("Cannot delete meta rule with model")
    code = 400
    title = 'Meta rule With Model Error'
    logger = "Error"


class DeleteMetaRuleWithRule(MoonError):
    description = _("Cannot delete meta rule with rule")
    code = 400
    title = 'Meta rule With Model Error'
    logger = "Error"


class DataContentError(MoonError):
    description = _("The data Content Error.")
    code = 400
    title = 'Data Content Error'
    logger = "Error"


class DataUnknown(MoonError):
    description = _("The data unknown.")
    code = 400
    title = 'Data Unknown'
    logger = "Error"


class ValidationContentError(MoonError):
    description = _("The Content validation incorrect.")
    code = 400
    title = 'Invalid Content'
    logger = "Error"

    def __init__(self, message=""):
        self.message = message
        super().__init__(message)

    def __str__(self):
        return self.message


class ValidationKeyError(MoonError):
    description = _("The Key validation incorrect.")
    code = 400
    title = 'Invalid Key'
    logger = "Error"

    def __init__(self, message=""):
        self.message = message
        super().__init__(message)

    def __str__(self):
        return self.message


class ForbiddenOverride(MoonError):
    description = _("Forbidden override flag.")
    code = 500
    title = 'Forbidden override.'
    logger = "Error"


class InvalidJson(MoonError):
    description = _("Invalid Json")
    code = 400
    title = 'Invalid Json.'
    logger = "Error"


class UnknownName(MoonError):
    description = _("Name is Unknown")
    code = 400
    title = 'Unknown Name.'
    logger = "Error"


class UnknownId(MoonError):
    description = _("ID is Unknown")
    code = 400
    title = 'Unknown ID.'
    logger = "Error"


class MissingIdOrName(MoonError):
    description = _("Name or ID is missing")
    code = 400
    title = 'Missing ID or Name.'
    logger = "Error"


class UnknownField(MoonError):
    description = _("Field is Unknown")
    code = 400
    title = 'Unknown Field.'
    logger = "Error"


class DecryptError(MoonError):
    description = _("Cannot decrypt API key")
    code = 401
    title = 'API Key Error.'
    logger = "Error"


class EncryptError(MoonError):
    description = _("Cannot encrypt API key")
    code = 401
    title = 'API Key Error.'
    logger = "Error"


class AttributeUnknownError(MoonError):
    description = _("Cannot find attribute")
    code = 401
    title = 'Attribute Error.'
    logger = "Error"


class AttributeValueUnknownError(MoonError):
    description = _("Cannot find value for this attribute")
    code = 401
    title = 'Attribute Value Error.'
    logger = "Error"