Mercurial > hg > orthanc
comparison Core/Enumerations.cpp @ 1577:7aac0cddd42e
generation of the error codes from a Python script
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 15:10:45 +0200 |
parents | de54c19fc44d |
children | 09715095fc53 |
comparison
equal
deleted
inserted
replaced
1576:de54c19fc44d | 1577:7aac0cddd42e |
---|---|
42 { | 42 { |
43 const char* EnumerationToString(ErrorCode error) | 43 const char* EnumerationToString(ErrorCode error) |
44 { | 44 { |
45 switch (error) | 45 switch (error) |
46 { | 46 { |
47 case ErrorCode_Custom: | |
48 return "Custom error, see the attached error message"; | |
49 | |
47 case ErrorCode_Success: | 50 case ErrorCode_Success: |
48 return "Success"; | 51 return "Success"; |
49 | 52 |
50 case ErrorCode_Custom: | |
51 return "Custom error, see the attached error message"; | |
52 | |
53 case ErrorCode_InternalError: | 53 case ErrorCode_InternalError: |
54 return "Internal error"; | 54 return "Internal error"; |
55 | 55 |
56 case ErrorCode_NotImplemented: | 56 case ErrorCode_NotImplemented: |
57 return "Not implemented yet"; | 57 return "Not implemented yet"; |
66 return "Bad type for a parameter"; | 66 return "Bad type for a parameter"; |
67 | 67 |
68 case ErrorCode_BadSequenceOfCalls: | 68 case ErrorCode_BadSequenceOfCalls: |
69 return "Bad sequence of calls"; | 69 return "Bad sequence of calls"; |
70 | 70 |
71 case ErrorCode_InexistentItem: | |
72 return "Accessing an inexistent item"; | |
73 | |
74 case ErrorCode_BadRequest: | |
75 return "Bad request"; | |
76 | |
77 case ErrorCode_NetworkProtocol: | |
78 return "Error in the network protocol"; | |
79 | |
80 case ErrorCode_SystemCommand: | |
81 return "Error while calling a system command"; | |
82 | |
83 case ErrorCode_Database: | |
84 return "Error with the database engine"; | |
85 | |
71 case ErrorCode_UriSyntax: | 86 case ErrorCode_UriSyntax: |
72 return "Badly formatted URI"; | 87 return "Badly formatted URI"; |
73 | 88 |
74 case ErrorCode_InexistentFile: | 89 case ErrorCode_InexistentFile: |
75 return "Inexistent file"; | 90 return "Inexistent file"; |
76 | 91 |
92 case ErrorCode_CannotWriteFile: | |
93 return "Cannot write to file"; | |
94 | |
77 case ErrorCode_BadFileFormat: | 95 case ErrorCode_BadFileFormat: |
78 return "Bad file format"; | 96 return "Bad file format"; |
79 | 97 |
80 case ErrorCode_CannotWriteFile: | |
81 return "Cannot write to file"; | |
82 | |
83 case ErrorCode_Timeout: | 98 case ErrorCode_Timeout: |
84 return "Timeout"; | 99 return "Timeout"; |
85 | 100 |
86 case ErrorCode_UnknownResource: | 101 case ErrorCode_UnknownResource: |
87 return "Unknown resource"; | 102 return "Unknown resource"; |
90 return "Incompatible version of the database"; | 105 return "Incompatible version of the database"; |
91 | 106 |
92 case ErrorCode_FullStorage: | 107 case ErrorCode_FullStorage: |
93 return "The file storage is full"; | 108 return "The file storage is full"; |
94 | 109 |
95 case ErrorCode_InexistentItem: | |
96 return "Accessing an inexistent item"; | |
97 | |
98 case ErrorCode_BadRequest: | |
99 return "Bad request"; | |
100 | |
101 case ErrorCode_NetworkProtocol: | |
102 return "Error in the network protocol"; | |
103 | |
104 case ErrorCode_CorruptedFile: | 110 case ErrorCode_CorruptedFile: |
105 return "Corrupted file (inconsistent MD5 hash)"; | 111 return "Corrupted file (inconsistent MD5 hash)"; |
106 | 112 |
107 case ErrorCode_InexistentTag: | 113 case ErrorCode_InexistentTag: |
108 return "Inexistent tag"; | 114 return "Inexistent tag"; |
109 | 115 |
110 case ErrorCode_ReadOnly: | 116 case ErrorCode_ReadOnly: |
111 return "Cannot modify a read-only data structure"; | 117 return "Cannot modify a read-only data structure"; |
112 | 118 |
119 case ErrorCode_IncompatibleImageFormat: | |
120 return "Incompatible format of the images"; | |
121 | |
113 case ErrorCode_IncompatibleImageSize: | 122 case ErrorCode_IncompatibleImageSize: |
114 return "Incompatible size of the images"; | 123 return "Incompatible size of the images"; |
115 | 124 |
116 case ErrorCode_IncompatibleImageFormat: | |
117 return "Incompatible format of the images"; | |
118 | |
119 case ErrorCode_SharedLibrary: | 125 case ErrorCode_SharedLibrary: |
120 return "Error while using a shared library (plugin)"; | 126 return "Error while using a shared library (plugin)"; |
121 | 127 |
122 case ErrorCode_SystemCommand: | |
123 return "Error while calling a system command"; | |
124 | |
125 case ErrorCode_Plugin: | 128 case ErrorCode_Plugin: |
126 return "Error encountered inside a plugin"; | 129 return "Error encountered inside a plugin"; |
127 | |
128 case ErrorCode_Database: | |
129 return "Error with the database engine"; | |
130 | 130 |
131 default: | 131 default: |
132 return "Unknown error code"; | 132 return "Unknown error code"; |
133 } | 133 } |
134 } | 134 } |
924 HttpStatus ConvertErrorCodeToHttpStatus(ErrorCode error) | 924 HttpStatus ConvertErrorCodeToHttpStatus(ErrorCode error) |
925 { | 925 { |
926 switch (error) | 926 switch (error) |
927 { | 927 { |
928 case ErrorCode_Success: | 928 case ErrorCode_Success: |
929 { | |
930 return HttpStatus_200_Ok; | 929 return HttpStatus_200_Ok; |
931 } | 930 |
931 case ErrorCode_ParameterOutOfRange: | |
932 return HttpStatus_400_BadRequest; | |
933 | |
934 case ErrorCode_BadParameterType: | |
935 return HttpStatus_400_BadRequest; | |
936 | |
937 case ErrorCode_InexistentItem: | |
938 return HttpStatus_404_NotFound; | |
939 | |
940 case ErrorCode_BadRequest: | |
941 return HttpStatus_400_BadRequest; | |
942 | |
943 case ErrorCode_UriSyntax: | |
944 return HttpStatus_400_BadRequest; | |
932 | 945 |
933 case ErrorCode_InexistentFile: | 946 case ErrorCode_InexistentFile: |
934 case ErrorCode_InexistentItem: | 947 return HttpStatus_404_NotFound; |
948 | |
949 case ErrorCode_BadFileFormat: | |
950 return HttpStatus_400_BadRequest; | |
951 | |
952 case ErrorCode_UnknownResource: | |
953 return HttpStatus_404_NotFound; | |
954 | |
935 case ErrorCode_InexistentTag: | 955 case ErrorCode_InexistentTag: |
936 case ErrorCode_UnknownResource: | |
937 { | |
938 return HttpStatus_404_NotFound; | 956 return HttpStatus_404_NotFound; |
939 } | 957 |
940 | 958 default: |
941 case ErrorCode_BadFileFormat: | |
942 case ErrorCode_BadParameterType: | |
943 case ErrorCode_BadRequest: | |
944 case ErrorCode_ParameterOutOfRange: | |
945 case ErrorCode_UriSyntax: | |
946 { | |
947 return HttpStatus_400_BadRequest; | |
948 break; | |
949 } | |
950 | |
951 default: | |
952 { | |
953 return HttpStatus_500_InternalServerError; | 959 return HttpStatus_500_InternalServerError; |
954 } | |
955 } | 960 } |
956 } | 961 } |
957 } | 962 } |