• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

問題を作成する

レコード処理された例外

構文

Java

NewRelic.recordHandledException(Exception $exceptionToHandle)
NewRelic.recordHandledException(Exception $exceptionToHandle, Map of String, Object $exceptionAttributes)
NewRelic.recordHandledException(Throwable $throwableToHandle)
NewRelic.recordHandledException(Throwable $throwableToHandle, Map of String, Object $exceptionAttributes)

コトリン [#kotlin]

NewRelic.recordHandledException(
exception: Exception?,
exceptionAttributes: Map<String?, Any?>?
)
NewRelic.recordHandledException(throwable: Throwable?)
NewRelic. recordHandledException(
throwable: Throwable?,
attributes: Map<String?, Any?>?
)

説明 [#description]

処理された例外またはその他のスロー可能な型を記録する。オプションで、コンテキストを示す追加属性を持つマップを取ることができます。

try{...} catch(){...}ブロック内でrecordHandledException()を使用すると、アプリケーションが例外をスローする頻度と状況を把握できます。

関連するカスタム属性に加えて、イベントには関連する セッション属性 があります。イベントデータは、モバイルモニタリングUIの Crash event trail 、またはNRQL経由で見ることができます。

パラメーター [#parameters]

パラメータ

タイプ

説明

$exceptionToHandle

Exception

必要。記録される例外。

$exceptionAttributes

Map of String, Object

オプション。例外に関連付けられる属性のマップ。

戻り値 [#return-values]

正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#examples]

以下は、クリック時リスナー内から ClassCastException を記録する例です。

Java [#java]

public class MainActivity extends Activity {
...
coolButton.setOnClickListener(new View.OnClickListener() {
Map myMap = new HashMap<>();
@Override
public void onClick(View view) {
try {
myMap.put("Key", "Value");
Integer stringVar = (Integer) myMap.get("Key"); //throws ClassCastException
} catch (Exception e) {
NewRelic.recordHandledException(e, myMap);
}
}
});
...
}

コトリン [#kotlin]

class MainActivity : AppCompatActivity() {
....
binding.fab.setOnClickListener { view ->
val myMap = mutableMapOf<String,Any>()
try {
myMap["Key"] = "Value"
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAnchorView(R.id.fab)
.setAction("Action", null).show()
}catch (exception:Exception) {
NewRelic.recordHandledException(exception,myMap)
}
}
........

構文

目的-c

recordHandledException:(NSException* __nonnull)exception withAttributes:(NSDictionary* __nullable)attributes;

説明 [#description]

処理された例外を記録します (Objective-c のみ)。オプションで、コンテキストを示す追加属性を含むマップを取得します。

recordHandledException APIはクラッシュ分析に役立ちます。キャプチャされたイベントは、アプリケーションが例外をスローする頻度とその条件を理解するのに役立ちます。関連するカスタム属性に加えて、イベントには関連するセッション属性もあります。

このAPIは、 NSExceptionのインスタンスとオプションのNSDictionary属性ディクショナリを取得してから、 recordHandledExceptionイベントを作成します。クラッシュイベントトレイルUIでイベントデータを表示し、NRQLでクエリを実行できます。

重要

この関数は Swift コードでは使用しないでください。Swift コードで処理されたエラーを追跡するには、 recordError を使用してください。

パラメーター [#parameters]

パラメータ

タイプ

説明

exception

NSException

必要。記録される例外。

attributes​

NSDictionary

任意です。コンテキストを与える属性の辞書。

戻り値 [#return-values]

イベントが正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#examples]

以下に、処理される単純な例外の例を示します。

@try {
@throw [NSException exceptionWithName:@"versionException"
reason:@"App version no longer supported"
userInfo:nil];
} @catch (NSException* e) {
[NewRelic recordHandledException:e];
}

別の例、または辞書を使用して処理された例外を次に示します。

NSException *exception = [NSException exceptionWithName:@"MyException" reason:@"I have my reason" userInfo:nil];
NSDictionary* dictionary = @{@"int": @1,
@"Test Group" : @"A | B"};
[NewRelic recordHandledException:exception withAttributes:dictionary];

構文

recordError(error, StackTrace.current, attributes: attributes);

説明 [#description]

致命的ではない例外を手動で記録します。

パラメーター [#parameters]

パラメータ

タイプ

説明

exception

Exception

必要。記録される例外。

戻り値 [#return-values]

イベントが正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#example]

try {
some_code_that_throws_error();
} catch (ex) {
NewrelicMobile.instance
.recordError(error, StackTrace.current, attributes: attributes);
}

構文

RecordException(System.Exception exception) : void;

説明 [#description]

処理された例外を記録します。オプションで、コンテキストを示す追加の属性を持つマップを取ります。

パラメーター [#parameters]

パラメータ

タイプ

説明

exception

Exception

必要。記録される例外。

戻り値 [#return-values]

イベントが正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#example]

try {
some_code_that_throws_error();
} catch (Exception ex) {
CrossNewRelic.Current.RecordException(ex);
}

構文

RecordException(System.Exception exception) : void;

説明 [#description]

処理された例外を手動で記録します。

パラメーター [#parameters]

パラメータ

タイプ

説明

exception

Exception

必要。記録される例外。

戻り値 [#return-values]

イベントが正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#example]

try {
some_code_that_throws_error();
} catch (Exception ex) {
NewRelicAgent.RecordException(e);
}

構文

RecordException(System.Exception exception) : void;

説明 [#description]

処理された例外を手動で記録します。

パラメーター [#parameters]

パラメータ

タイプ

説明

exception

Exception

必要。記録される例外。

戻り値 [#return-values]

イベントが正常に記録された場合はtrueを返し、そうでない場合はfalseを返します。

[#example]

try {
some_code_that_throws_error();
} catch (Exception ex) {
CrossNewRelicClient.Current.RecordException(ex);
}
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.