Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f4e442fe
Unverified
Commit
f4e442fe
authored
Aug 10, 2020
by
Jonah Williams
Committed by
GitHub
Aug 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add native stacktrace field for PlatformException (#62828)" (#63431)
This reverts commit
74b5051c
.
parent
74b5051c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
42 deletions
+10
-42
message_codec.dart
packages/flutter/lib/src/services/message_codec.dart
+4
-16
message_codecs.dart
packages/flutter/lib/src/services/message_codecs.dart
+6
-12
message_codecs_test.dart
packages/flutter/test/services/message_codecs_test.dart
+0
-12
platform_channel_test.dart
packages/flutter/test/services/platform_channel_test.dart
+0
-2
No files found.
packages/flutter/lib/src/services/message_codec.dart
View file @
f4e442fe
...
...
@@ -80,10 +80,9 @@ abstract class MethodCodec {
/// Encodes an error result into a binary envelope.
///
/// The specified error [code], human-readable error [message], error
/// [details] correspond to the fields of [PlatformException] and error
/// [stacktrace] correspond to stacktrace from native platforms.
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
,
String
?
stacktrace
});
/// The specified error [code], human-readable error [message], and error
/// [details] correspond to the fields of [PlatformException].
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
});
}
...
...
@@ -108,7 +107,6 @@ class PlatformException implements Exception {
required
this
.
code
,
this
.
message
,
this
.
details
,
this
.
stacktrace
,
})
:
assert
(
code
!=
null
);
/// An error code.
...
...
@@ -120,18 +118,8 @@ class PlatformException implements Exception {
/// Error details, possibly null.
final
dynamic
details
;
/// Native stacktrace for the error, possibly null.
/// This is strictly for native platform stacktrace.
/// The stacktrace info on dart platform can be found within the try-catch block for example:
/// try {
/// ...
/// } catch (e, stacktrace) {
/// print(stacktrace);
/// }
final
String
?
stacktrace
;
@override
String
toString
()
=>
'PlatformException(
$code
,
$message
,
$details
,
$stacktrace
)'
;
String
toString
()
=>
'PlatformException(
$code
,
$message
,
$details
)'
;
}
/// Thrown to indicate that a platform interaction failed to find a handling
...
...
packages/flutter/lib/src/services/message_codecs.dart
View file @
f4e442fe
...
...
@@ -144,15 +144,13 @@ class JSONMethodCodec implements MethodCodec {
throw
FormatException
(
'Expected envelope List, got
$decoded
'
);
if
(
decoded
.
length
==
1
)
return
decoded
[
0
];
if
(
decoded
.
length
==
4
if
(
decoded
.
length
==
3
&&
decoded
[
0
]
is
String
&&
(
decoded
[
1
]
==
null
||
decoded
[
1
]
is
String
)
&&
(
decoded
[
3
]
==
null
||
decoded
[
3
]
is
String
))
&&
(
decoded
[
1
]
==
null
||
decoded
[
1
]
is
String
))
throw
PlatformException
(
code:
decoded
[
0
]
as
String
,
message:
decoded
[
1
]
as
String
,
details:
decoded
[
2
],
stacktrace:
decoded
[
3
]
as
String
,
);
throw
FormatException
(
'Invalid envelope:
$decoded
'
);
}
...
...
@@ -163,9 +161,9 @@ class JSONMethodCodec implements MethodCodec {
}
@override
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
,
String
?
stacktrace
})
{
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
})
{
assert
(
code
!=
null
);
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
code
,
message
,
details
,
stacktrace
])!;
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
code
,
message
,
details
])!;
}
}
...
...
@@ -549,13 +547,12 @@ class StandardMethodCodec implements MethodCodec {
}
@override
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
,
String
?
stacktrace
})
{
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
})
{
final
WriteBuffer
buffer
=
WriteBuffer
();
buffer
.
putUint8
(
1
);
messageCodec
.
writeValue
(
buffer
,
code
);
messageCodec
.
writeValue
(
buffer
,
message
);
messageCodec
.
writeValue
(
buffer
,
details
);
messageCodec
.
writeValue
(
buffer
,
stacktrace
);
return
buffer
.
done
();
}
...
...
@@ -570,11 +567,8 @@ class StandardMethodCodec implements MethodCodec {
final
dynamic
errorCode
=
messageCodec
.
readValue
(
buffer
);
final
dynamic
errorMessage
=
messageCodec
.
readValue
(
buffer
);
final
dynamic
errorDetails
=
messageCodec
.
readValue
(
buffer
);
/// TODO(libe, b/158148913): Mute the readValue check for stacktrace for now.
/// Remove this once flutter engine is ready with the stacktrace fields.
final
String
?
errorStacktrace
=
(
buffer
.
hasRemaining
)
?
messageCodec
.
readValue
(
buffer
)
as
String
:
null
;
if
(
errorCode
is
String
&&
(
errorMessage
==
null
||
errorMessage
is
String
)
&&
!
buffer
.
hasRemaining
)
throw
PlatformException
(
code:
errorCode
,
message:
errorMessage
as
String
,
details:
errorDetails
,
stacktrace:
errorStacktrace
);
throw
PlatformException
(
code:
errorCode
,
message:
errorMessage
as
String
,
details:
errorDetails
);
else
throw
const
FormatException
(
'Invalid envelope'
);
}
...
...
packages/flutter/test/services/message_codecs_test.dart
View file @
f4e442fe
...
...
@@ -9,9 +9,7 @@
import
'dart:typed_data'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:matcher/matcher.dart'
;
import
'../flutter_test_alternative.dart'
;
import
'message_codecs_testing.dart'
;
...
...
@@ -46,15 +44,6 @@ void main() {
expect
(
string
.
decodeMessage
(
offsetByteData
),
' world'
);
});
});
group
(
'Decode envelope'
,
()
{
const
MethodCodec
method
=
StandardMethodCodec
();
const
MessageCodec
<
String
>
string
=
StringCodec
();
const
StandardMessageCodec
standard
=
StandardMessageCodec
();
test
(
'should decode native stacktrace.'
,
()
{
final
ByteData
errorData
=
method
.
encodeErrorEnvelope
(
code:
'errorCode'
,
message:
'errorMessage'
,
details:
'errorDetails'
,
stacktrace:
'errorStacktrace'
,);
expect
(()
=>
method
.
decodeEnvelope
(
errorData
),
throwsA
(
predicate
((
e
)
=>
e
is
PlatformException
&&
e
.
stacktrace
==
'errorStacktrace'
)));
});
});
group
(
'JSON message codec'
,
()
{
const
MessageCodec
<
dynamic
>
json
=
JSONMessageCodec
();
test
(
'should encode and decode simple messages'
,
()
{
...
...
@@ -169,4 +158,3 @@ void main() {
});
});
}
packages/flutter/test/services/platform_channel_test.dart
View file @
f4e442fe
...
...
@@ -131,7 +131,6 @@ void main() {
'bad'
,
'Something happened'
,
<
String
,
dynamic
>{
'a'
:
42
,
'b'
:
3.14
},
'errorStacktrace'
,
]);
},
);
...
...
@@ -142,7 +141,6 @@ void main() {
expect
(
e
.
code
,
equals
(
'bad'
));
expect
(
e
.
message
,
equals
(
'Something happened'
));
expect
(
e
.
details
,
equals
(<
String
,
dynamic
>{
'a'
:
42
,
'b'
:
3.14
}));
expect
(
e
.
stacktrace
,
equals
(
'errorStacktrace'
));
}
catch
(
e
)
{
fail
(
'PlatformException expected'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment