1 // OpenTween - Client of Twitter
2 // Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3 // All rights reserved.
5 // This file is part of OpenTween.
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
23 using System.Collections.Generic;
25 using System.Runtime.Serialization;
27 using System.Threading.Tasks;
29 namespace OpenTween.Api.DataModel
31 // 参照: https://dev.twitter.com/docs/error-codes-responses
34 public class TwitterError
36 [DataMember(Name = "errors")]
37 public TwitterErrorItem[] Errors { get; set; }
39 /// <exception cref="SerializationException"/>
40 public static TwitterError ParseJson(string json)
41 => MyCommon.CreateDataFromJson<TwitterError>(json);
45 public class TwitterErrorItem
47 [DataMember(Name = "code")]
48 public TwitterErrorCode Code { get; set; }
50 [DataMember(Name = "message")]
51 public string Message { get; set; }
53 public override string ToString()
55 if (Enum.IsDefined(typeof(TwitterErrorCode), this.Code))
56 return this.Code.ToString();
63 /// Twitter API から返されるエラーコード
65 public enum TwitterErrorCode
68 /// 不正なリクエスト等によって認証を完了できない場合に発生する。大体クライアントのせい
73 /// 指定されたリソースが存在しません。HTTP 404 と同等
80 SuspendedAccount = 64,
83 /// REST API v1 は星になりました
93 /// アクセストークンが無効です。不正なトークンまたはユーザーによって失効されています
98 /// SSLを使わずにAPIに接続することはできません
103 /// サーバーの過負荷によって一時的にアクセスできません
113 /// oauth_timestamp の時刻が無効。クライアントかサーバーの時計が大幅にずれている
115 TimestampOutOfRange = 135,
118 /// ユーザーからブロックされている (公式ドキュメントに記述無し)
123 /// 既にふぁぼっているツイートをふぁぼろうとした (公式ドキュメントに記述無し)
125 AlreadyFavorited = 139,
130 StatusNotFound = 144,
133 /// 投稿されたメッセージが重複しています
136 /// “There was an error sending your message: Whoops! You already said that.”
137 /// /direct_messages/new.json で重複するDMを送信すると発生
139 DuplicateMessage = 151,
147 /// 非公開ユーザーのため閲覧できません
152 /// 一日当たりの投稿可能なツイート数の制限に達しました
154 DailyLimitReached = 185,
157 /// 投稿されたステータスが重複しています
159 DuplicateStatus = 187,
162 /// 認証が必要な API で認証データが含まれていない、または認証データが不正
164 AuthenticationRequired = 215,
167 /// スパムの疑いのあるリクエストがブロックされました
169 RequestBlocked = 226,
174 RetiredEndpoint = 251,
177 /// アプリケーションの書き込み権限が規制されています
179 AppWriteRestricted = 261,
182 /// 自分自身をミュートに設定することはできません
184 CantMuteYourself = 271,
187 /// ミュート設定されていないユーザーをミュート解除しようとしています
195 /// “Direct Message is a duplicate.”
196 /// /statuses/update.json に「D screen_name ...」形式で重複したDMを送信すると発生
201 /// DMで投稿可能な文字数を超えています
203 DMCharacterLimit = 354,