1 /*
2  * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "ModelError.h"
18 
19 using namespace AlibabaCloud::OSS;
20 
GetArgErrorMsg(const int code)21 static const char * GetArgErrorMsg(const int code)
22 {
23     static const char * msg[] =
24     {
25         "Argument is invalid, please check.",
26         /*Common 1-2*/
27         "The bucket name is invalid. A bucket name must  be comprised of lower-case characters, numbers or dash(-) with 3-63 characters long.",
28         "The object key is invalid. An object name should be between 1-1023 bytes long and cannot begin with '/' or '\\'",
29         /*CORS   3-10*/
30         "One bucket not allow exceed ten item of CORSRules.",
31         "CORSRule.AllowedOrigins should not be empty.",
32         "CORSRule.AllowedOrigins allowes at most one asterisk wildcard.",
33         "CORSRule.AllowedMethods should not be empty.",
34         "CORSRule.AllowedMethods only supports GET/PUT/DELETE/POST/HEAD.",
35         "CORSRule.AllowedHeaders allowes at most one asterisk wildcard.",
36         "CORSRule.ExposedHeader dose not allowe asterisk wildcard.",
37         "CORSRule.MaxAgeSeconds should not be less than 0 or greater than 999999999.",
38         /*Logging -11*/
39         "Invalid logging prefix.",
40         /*storageCapacity -12*/
41         "Storage capacity must greater than -1.",
42         /*WebSiet -13*/
43         "Index document must not be empty.",
44         "Invalid index document, must be end with.html.",
45         "Invalid error document, must be end with .html.",
46         /*iostream request body -16*/
47         "Request body is null.",
48         "Request body is in fail state. Logical error on i/o operation.",
49         "Request body is in bad state. Read/writing error on i/o operation.",
50         /*MultipartUpload -19*/
51         "PartList is empty.",
52         "PartSize should not be less than 100*1024 or greater than 5*1024*1024*1024.",
53         "PartNumber should not be less than 1 or greater than 10000.",
54         /*Lifecycle Rules -22*/
55         "One bucket not allow exceed one thousand item of LifecycleRules.",
56         "LifecycleRule should not be null or empty.",
57         "Only one expiration property should be specified.",
58         "You have a rule for a prefix, and therefore you cannot create the rule for the whole bucket.",
59         "Configure at least one of file and fragment lifecycle.",
60         /*ResumableUpload -27*/
61         "The path of file to upload is empty.",
62         "Open upload file failed.",
63         "The part size is less than 100KB.",
64         "The thread num is less than 1.",
65         "Checkpoint directory is not exist.",
66         "Parse resumable upload record failed.",
67         "Upload file has been modified since last upload.",
68         "Upload record is invalid, it has been modified.",
69         /*ResumableCopy -35*/
70         "Parse resumable copy record failed.",
71         "Source object has been modified since last copy.",
72         "Copy record is invalid, it has been modified.",
73         /*ResumableDownload -38*/
74         "Invalid range of resumable download",
75         "The path of file download to is empty",
76         "Source object has been modified since last download.",
77         "Parse resumable download record failed.",
78         "invalid range values in download record record file.",
79         "Range values has been modified since last download.",
80         "Open temp file for download failed",
81         /*GetObject -45*/
82         "The range is invalid. The start should not be less than 0 or less then the end. The end could be -1 to get the rest of the data.",
83         /*LiveChannel -46*/
84         "The status param is invalid, it must be 'enabled' or 'disabled' ",
85         "The channelName param is invalid, it shouldn't contain '/' and length < 1023",
86         "The dest bucket name is invalid",
87         "The live channel description is invalied, it should be shorter than 129",
88         "The channel type is invalid, it shoudld only be HLS",
89         "The live channel frag duration param is invalid, it should be [1,100]",
90         "The live channel frag count param is invalid, it should be [1,100]",
91         "The live channel play list param is invalid, it should end with '.m3u8' & length in [6,128]",
92         "The snapshot param is invalid, please check.",
93         "The time param is invalid, endTime should bigger than startTime and difference smaller than 24*60*60",
94         "The Max Key param is invalid, it's default valus is 100, and smaller than 1000",
95         /*SelectObject -57*/
96         "The range is invalid. It cannot set lien range and split range at the same time.",
97         "The line range is invalid. The start should not be less than 0 or less then the end. The end could be -1 to get the rest of the data.",
98         "The split range is invalid. The start should not be less than 0 or less then the end. The end could be -1 to get the rest of the data.",
99         "The select object expressiontype must is SQL.",
100         "The select object content checksum failed.",
101         "The request InputFormat/OutputFormat is invalid. It cannot set InputFormat or OutputFormat as nullptr.",
102         "The request InputFormat/OutputFormat is invalid. It cannot set InputFormat and OutputFormat in difficent type.",
103         /*CreateSelectObject -64*/
104         "The request InputFormat is invalid. It cannot set InputFormat as nullptr.",
105         /*Tagging -65*/
106         "Object tags cannot be greater than 10.",
107         "Object Tag key is invalid, it's length should be [1, 128].",
108         "Object Tag value is invalid, it's length should be less than 256.",
109         /*Resumable for wstring path -68*/
110         "Only support wstring path in windows os.",
111         "The type of filePath and checkpointDir should be the same, either string or wstring."
112     };
113 
114     int index = code - ARG_ERROR_START;
115     int msg_size = sizeof(msg)/sizeof(msg[0]);
116     if (code < ARG_ERROR_START || index > msg_size) {
117         index = 0;
118     }
119 
120     return msg[index];
121 }
122 
123 
GetModelErrorMsg(const int code)124 const char * AlibabaCloud::OSS::GetModelErrorMsg(const int code)
125 {
126     if (code >= ARG_ERROR_START && code <= ARG_ERROR_END) {
127         return GetArgErrorMsg(code);
128     }
129 
130     return "Model error, but undefined.";
131 }
132