Add OasstError exception class and exception filter

This commit is contained in:
Andreas Köpf
2022-12-28 14:10:15 +01:00
parent 99bf737117
commit dda668bcd5
7 changed files with 105 additions and 42 deletions
+26
View File
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
Open-Assistant backend API error codes.
"""
# 0-1000: general errors
GENERIC_ERROR = 0
DATABASE_URI_NOT_SET = 1
API_CLIENT_NOT_AUTHORIZED = 2
# 1000-2000: tasks endpoint
TASK_INVALID_REQUEST_TYPE = 1000
TASK_ACK_FAILED = 1001
TASK_INVALID_RESPONSE_TYPE = 1002
TASK_INTERACTION_REQUEST_FAILED = 1003
TASK_GENERATION_FAILED = 1004
# 2000-3000: prompt_repository
INVALID_POST_ID = 2000
POST_NOT_FOUND = 2001
RATING_OUT_OF_RANGE = 2002
INVALID_RANKING_VALUE = 2003
WORK_PACKAGE_NOT_FOUND = 2004
WORK_PACKAGE_EXPIRED = 2005
WORK_PACKAGE_PAYLOAD_TYPE_MISMATCH = 2006
INVALID_TASK_TYPE = 2007
USER_NOT_SPECIFIED = 2008