diff --git a/lib/src/pictrs.dart b/lib/src/pictrs.dart index 09165ef..12b21e8 100644 --- a/lib/src/pictrs.dart +++ b/lib/src/pictrs.dart @@ -24,6 +24,14 @@ class PictrsApi { req.headers['Cookie'] = 'jwt=$auth'; final res = await req.send(); + if (res.statusCode != 201) { + switch (res.statusCode) { + case 413: + throw const LemmyApiException('pictrs_payload_too_large'); + default: + throw const LemmyApiException('pictrs_unknown_error'); + } + } final Map body = jsonDecode(utf8.decode(await res.stream.toBytes())); body['instance_host'] = host;