greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.88k stars 475 forks source link

Weather block output #309

Closed trmendes closed 5 years ago

trmendes commented 5 years ago

I'm getting a message output: "Error in block: 'weather': Malformed JSON'

2018-12-01 07:39:49 - [swaybar/i3bar.c:199] Received i3bar json: '[{"background":null,"color":"#282828","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#282828","color":"#ebdbb2","full_text":"   ","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","separator":false,"separator_block_width":0},{"background":"#000000","color":"#282828","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#282828","color":"#ebdbb2","full_text":"   ","name":"pacman","separator":false,"separator_block_width":0},{"background":"#282828","color":"#000000","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","separator":false,"separator_block_width":0},{"background":"#000000","color":"#282828","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#282828","color":"#ebdbb2","full_text":"  81% ","name":"d00337b30f00476aafb15a405cd7047c","separator":false,"separator_block_width":0},{"background":"#282828","color":"#000000","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","separator":false,"separator_block_width":0},{"background":"#000000","color":"#282828","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#282828","color":"#ebdbb2","full_text":"   ","name":"99f1b1ccdfca4286befa2eaa84d35369","separator":false,"separator_block_width":0},{"background":"#282828","color":"#000000","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000","color":"#000000","full_text":"","separator":false,"separator_block_width":0},{"background":"#000000","color":"#282828","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#282828","color":"#ebdbb2","full_text":"   ","name":"8afa10d001e045d68fca605bf22ae194","separator":false,"separator_block_width":0}]'
2018-12-01 07:39:49 - [swaybar/i3bar.c:253] Rendering last received json

Error in block 'weather': Malformed JSON.
2018-12-01 07:39:50 - [swaybar/i3bar.c:199] Received i3bar json: '[{"background":"#000000","color":"#dc322f","full_text":" Error in block 'weather': Malformed JSON. ","separator":false,"separator_block_width":0}]'
2018-12-01 07:39:50 - [swaybar/i3bar.c:253] Rendering last received json

Ref: https://github.com/greshake/i3status-rust/blob/master/src/blocks/weather.rs#L100-L148

It might be better to output this error in other way (maybe part of the json) because once in a while this json parsing fails and then my i3statusbar is replaced complete by this message "Error in block...", because of that I have to disable the weather block so I can have my other blocks back.

atheriel commented 5 years ago

This is likely caused by our poor handling of curl failures, as discussed in #292. I'll mark this as a duplicate for now, since it's already clear we need a better approach there.