mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Parse error codes/messages from new JSON file.
Same python interface to this data, but the data can now be reused by clients in other languages (e.g. potentially automating the creation of typed Java exceptions).
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
[
|
||||
{
|
||||
"name": "UNKNOWN",
|
||||
"code": 0,
|
||||
"message": "Unknown error occurred while processing request."
|
||||
},
|
||||
{
|
||||
"name": "USER_CANNOT_RUN_AS",
|
||||
"code": 400001,
|
||||
"message": "User does not have permissions to run jobs as another user."
|
||||
},
|
||||
{
|
||||
"name": "USER_INVALID_RUN_AS",
|
||||
"code": 400002,
|
||||
"message": "Invalid run_as request - run_as user does not exist."
|
||||
},
|
||||
{
|
||||
"name": "USER_INVALID_JSON",
|
||||
"code": 400003,
|
||||
"message": "Your request did not appear to be valid JSON, please consult the API documentation."
|
||||
},
|
||||
{
|
||||
"name": "USER_OBJECT_ATTRIBUTE_INVALID",
|
||||
"code": 400004,
|
||||
"message": "Attempted to create or update object with invalid attribute value."
|
||||
},
|
||||
{
|
||||
"name": "USER_OBJECT_ATTRIBUTE_MISSING",
|
||||
"code": 400005,
|
||||
"message": "Attempted to create object without required attribute."
|
||||
},
|
||||
{
|
||||
"name": "USER_SLUG_DUPLICATE",
|
||||
"code": 400006,
|
||||
"message": "Slug must be unique per user."
|
||||
},
|
||||
{
|
||||
"name": "USER_NO_API_KEY",
|
||||
"code": 403001,
|
||||
"message": "API Authentication Required for this request"
|
||||
},
|
||||
{
|
||||
"name": "USER_CANNOT_ACCESS_ITEM",
|
||||
"code": 403002,
|
||||
"message": "User cannot access specified item."
|
||||
},
|
||||
{
|
||||
"name": "USER_DOES_NOT_OWN_ITEM",
|
||||
"code": 403003,
|
||||
"message": "User does not own specified item."
|
||||
},
|
||||
{
|
||||
"name": "USER_OBJECT_NOT_FOUND",
|
||||
"code": 404001,
|
||||
"message": "No such object not found."
|
||||
}
|
||||
]
|
||||
@@ -1,3 +1,6 @@
|
||||
from pkg_resources import resource_string
|
||||
from json import loads
|
||||
|
||||
# Error codes are provided as a convience to Galaxy API clients, but at this
|
||||
# time they do represent part of the more stable interface. They can change
|
||||
# without warning between releases.
|
||||
@@ -16,18 +19,14 @@ class ErrorCode( object ):
|
||||
def __int__( self ):
|
||||
return int( self.code )
|
||||
|
||||
# TODO: Guidelines for error message langauge?
|
||||
UNKNOWN = ErrorCode(0, UNKNOWN_ERROR_MESSAGE)
|
||||
@staticmethod
|
||||
def from_dict( entry ):
|
||||
name = entry.get("name")
|
||||
code = entry.get("code")
|
||||
message = entry.get("message")
|
||||
return ( name, ErrorCode( code, message ) )
|
||||
|
||||
USER_CANNOT_RUN_AS = ErrorCode(400001, "User does not have permissions to run jobs as another user.")
|
||||
USER_INVALID_RUN_AS = ErrorCode(400002, "Invalid run_as request - run_as user does not exist.")
|
||||
USER_INVALID_JSON = ErrorCode(400003, "Your request did not appear to be valid JSON, please consult the API documentation.")
|
||||
USER_OBJECT_ATTRIBUTE_INVALID = ErrorCode(400004, "Attempted to create or update object with invalid attribute value.")
|
||||
USER_OBJECT_ATTRIBUTE_MISSING = ErrorCode(400005, "Attempted to create object without required attribute.")
|
||||
USER_SLUG_DUPLICATE = ErrorCode(400006, "Slug must be unique per user.")
|
||||
|
||||
USER_NO_API_KEY = ErrorCode(403001, "API Authentication Required for this request")
|
||||
USER_CANNOT_ACCESS_ITEM = ErrorCode(403002, "User cannot access specified item.")
|
||||
USER_DOES_NOT_OWN_ITEM = ErrorCode(403003, "User does not own specified item.")
|
||||
|
||||
USER_OBJECT_NOT_FOUND = ErrorCode(404001, "No such object not found.")
|
||||
error_codes_json = resource_string( __name__, 'error_codes.json' )
|
||||
for entry in loads( error_codes_json ):
|
||||
name, error_code_obj = ErrorCode.from_dict( entry )
|
||||
globals()[ name ] = error_code_obj
|
||||
|
||||
Reference in New Issue
Block a user