Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An exception is not handled when Legato failed to post to Misskey (and Twitter?) #36

Open
siketyan opened this issue Sep 7, 2018 · 9 comments
Labels

Comments

@siketyan
Copy link
Member

siketyan commented Sep 7, 2018

Summary

When AIMP was playing music, .NET Framework under Legato caught an exception below.

How to reproduce

I couldn't find how to reproduce the exception.

Screenshot

image

Stacktrace of the Exception

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.JsonReader.ReadAndMoveToContent()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Misq.Core.<Request>d__0.MoveNext()
---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Misq.Me.<Request>d__13.MoveNext()
---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at LegatoNowPlaying.Services.Misskey.Service.<Post>d__7.MoveNext()
---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at LegatoNowPlaying.Accounts.<Post>d__3.MoveNext()
---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at LegatoNowPlaying.MainForm.<_PostAsync>d__19.MoveNext()
---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at LegatoNowPlaying.MainForm.<<MainForm_Load>b__24_0>d.MoveNext()
---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
@siketyan siketyan added the bug label Sep 7, 2018
@siketyan
Copy link
Member Author

siketyan commented Sep 7, 2018

I think it is a problem of server of Misskey, but I think Legato should add handling of this exception.

@siketyan siketyan changed the title An exception occurs when playing music An exception is not handled when Legato failed to post to Misskey (and Twitter?) Sep 7, 2018
@marihachi
Copy link
Contributor

marihachi commented Sep 8, 2018

どんなJSONを受け取った場合にどんな対策を取るべきかが分からないので、根本的な対策は難しそう
雑な対処の方法として、投稿時の例外は全部掴んでしまうというのがある

@siketyan
Copy link
Member Author

siketyan commented Sep 8, 2018

そもそもJSONがきてない(サーバエラーしてる)んだけどステータスコード見てる?

@marihachi
Copy link
Contributor

marihachi commented Sep 8, 2018

そもそも、それぞれのサービス(Twitter、Misskey)のHTTPレイヤーはそれぞれのライブラリによって隠蔽されているので、Legato-NowPlayingで関与すべきことではなさそう。
するとすれば、降ってきた例外を掴んでよしなにするくらいだと思う。

@marihachi
Copy link
Contributor

@marihachi
Copy link
Contributor

marihachi commented Sep 8, 2018

なんて例外が飛んできてる?
Newtonsoft.Json.JsonReaderExceptionだけかな

@siketyan
Copy link
Member Author

siketyan commented Sep 8, 2018

いまのところ確認できたのはそれぐらい
CoreTweetがTwitterException投げる要領でMisqもMisskeyExceptionとか投げてくれるといいんだけどね、と思いつつ

@marihachi
Copy link
Contributor

ふむ

@Asteriskx
Copy link
Member

この間の DDoS 攻撃時に起きてたぽいから、
API 介して接続が出来ていないときに例外吐いてそうっていう予想はしてる。
例外は JsonReaderException だけ拾ってるけど、 Siketyan も言ってる通り、
各サービスごとに throw してあげるのもいいのかもしれない。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants