File tree Expand file tree Collapse file tree
templates/flutter/lib/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import 'dart:convert';
12import 'dart:io';
23import 'dart:math';
34import 'package:cookie_jar/cookie_jar.dart';
@@ -427,6 +428,29 @@ class ClientIO extends ClientBase with ClientMixin {
427428 final key = url.queryParameters['key'];
428429 final secret = url.queryParameters['secret'];
429430 if (key == null || secret == null) {
431+ final error = url.queryParameters['error'];
432+ if (error != null && error.isNotEmpty) {
433+ try {
434+ final parsed = jsonDecode(error);
435+ if (parsed is Map) {
436+ final codeValue = parsed['code'];
437+ final int? code = codeValue is int
438+ ? codeValue
439+ : int.tryParse('${codeValue ?? ''}');
440+ throw {{spec .info .title | caseUcfirst }}Exception(
441+ parsed['message']?.toString() ?? error,
442+ code,
443+ parsed['type']?.toString(),
444+ error,
445+ );
446+ }
447+ } on {{spec .info .title | caseUcfirst }}Exception {
448+ rethrow;
449+ } catch (_) {
450+ // Fall through to a plain-string error when JSON is malformed.
451+ }
452+ throw {{spec .info .title | caseUcfirst }}Exception(error);
453+ }
430454 throw {{spec .info .title | caseUcfirst }}Exception(
431455 "Invalid OAuth2 Response. Key and Secret not available.",
432456 500,
You can’t perform that action at this time.
0 commit comments