Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ErrorLogResult.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.plugin.common;
6
7import androidx.annotation.Nullable;
8import io.flutter.BuildConfig;
9import io.flutter.Log;
10
11/**
12 * An implementation of {@link MethodChannel.Result} that writes error results to the Android log.
13 */
14public class ErrorLogResult implements MethodChannel.Result {
15 private String tag;
16 private int level;
17
18 public ErrorLogResult(String tag) {
19 this(tag, Log.WARN);
20 }
21
22 public ErrorLogResult(String tag, int level) {
23 this.tag = tag;
24 this.level = level;
25 }
26
27 @Override
28 public void success(@Nullable Object result) {}
29
30 @Override
31 public void error(
32 String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
33 String details = (errorDetails != null) ? " details: " + errorDetails : "";
34 if (level >= Log.WARN || BuildConfig.DEBUG) {
35 Log.println(level, tag, errorMessage + details);
36 }
37 }
38
39 @Override
40 public void notImplemented() {
41 if (level >= Log.WARN || BuildConfig.DEBUG) {
42 Log.println(level, tag, "method not implemented");
43 }
44 }
45}
static final boolean DEBUG
static int WARN
Definition Log.java:22
static void println(@NonNull int level, @NonNull String tag, @NonNull String message)
Definition Log.java:34
void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails)
void success(@Nullable Object result)
GAsyncResult * result