Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ja] Translate GPUUncapturedErrorEvent #23683

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions files/ja/web/api/gpuuncapturederrorevent/error/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "GPUUncapturedErrorEvent: error プロパティ"
slug: Web/API/GPUUncapturedErrorEvent/error
l10n:
sourceCommit: 89c435da452257b944b403cc9e45036fcb22590e
---

{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}

{{domxref("GPUUncapturedErrorEvent")}} インターフェイスの読み取り専用プロパティ **`error`** は、エラーの詳細へのアクセスを提供する {{domxref("GPUError")}} オブジェクトのインスタンスです。

## 値

{{domxref("GPUError")}} オブジェクトのインスタンスです。

## 例

例は、メインの [`GPUUncapturedErrorEvent`](/ja/docs/Web/API/GPUUncapturedErrorEvent#例) のページを参照してください。

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- [WebGPU API](/ja/docs/Web/API/WebGPU_API)
- [WebGPU Error Handling best practices](https://toji.dev/webgpu-best-practices/error-handling)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "GPUUncapturedErrorEvent: GPUUncapturedErrorEvent() コンストラクター"
slug: Web/API/GPUUncapturedErrorEvent/GPUUncapturedErrorEvent
l10n:
sourceCommit: 89c435da452257b944b403cc9e45036fcb22590e
---

{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}

**`GPUUncapturedErrorEvent()`** コンストラクターは、新しい {{domxref("GPUUncapturedErrorEvent")}} オブジェクトのインスタンスを生成します。

## 構文

```js-nolint
new GPUUncapturedErrorEvent(type, options)
```

### 引数

- `type`
- : エラーの種類を指定する列挙値です。以下の値のいずれかです。
- `"internal"`
- : エラーは {{domxref("GPUInternalError")}} です。
- `"out-of-memory"`
- : エラーは {{domxref("GPUOutOfMemoryError")}} です。
- `"validation"`
- : エラーは {{domxref("GPUValidationError")}} です。
- `options`
- : オブジェクトです。以下のプロパティを持つことができます。
- `error`
- : エラーの詳細へのアクセスを提供する {{domxref("GPUError")}} オブジェクトのインスタンスです。

## 例

開発者は、自分でこのコンストラクターを用いて `GPUUncapturedErrorEvent` オブジェクトを生成することはないでしょう。ユーザーエージェントは、{{domxref("GPUDevice")}} の {{domxref("GPUDevice.uncapturederror_event", "uncapturederror")}} イベントが発火したとき、予期せぬエラーをキャプチャできるようにするため、このコンストラクターを用いて適切なオブジェクトを生成します。

例は、メインの [`GPUUncapturedErrorEvent`](/ja/docs/Web/API/GPUUncapturedErrorEvent#例) のページを参照してください。

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- [WebGPU API](/ja/docs/Web/API/WebGPU_API)
- [WebGPU Error Handling best practices](https://toji.dev/webgpu-best-practices/error-handling)
58 changes: 58 additions & 0 deletions files/ja/web/api/gpuuncapturederrorevent/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: GPUUncapturedErrorEvent
slug: Web/API/GPUUncapturedErrorEvent
l10n:
sourceCommit: 89c435da452257b944b403cc9e45036fcb22590e
---

{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}

{{domxref("WebGPU API", "WebGPU API", "", "nocode")}} の **`GPUUncapturedErrorEvent`** インターフェイスは、{{domxref("GPUDevice")}} の {{domxref("GPUDevice.uncapturederror_event", "uncapturederror")}} イベント用のイベントオブジェクト型で、テレメトリーや予期せぬエラーの報告に使用されます。

エラーが発生する可能性を把握している場合は、{{domxref("GPUDevice.pushErrorScope", "pushErrorScope()")}} および {{domxref("GPUDevice.popErrorScope", "popErrorScope()")}} を用いて処理をするべきです。

{{InheritanceDiagram}}

## コンストラクター

- {{domxref("GPUUncapturedErrorEvent.GPUUncapturedErrorEvent", "GPUUncapturedErrorEvent()")}} {{Experimental_Inline}}
- : 新しい `GPUUncapturedErrorEvent` オブジェクトのインスタンスを生成します。

## インスタンスプロパティ

_親の {{domxref("Event")}} からプロパティを継承します。_

- {{domxref("GPUUncapturedErrorEvent.error", "error")}} {{Experimental_Inline}} {{ReadOnlyInline}}
- : エラーの詳細へのアクセスを提供する {{domxref("GPUError")}} オブジェクトのインスタンスです。

## 例

エラースコープで処理されなかったエラーをすべて拾ってキャプチャするグローバルな仕組みとして、以下のようなコードを使用できます。

```js
// ...

device.addEventListener("uncapturederror", (event) => {
// エラーを再浮上させる
console.error("WebGPU エラーがキャプチャされませんでした:", event.error.message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
console.error("WebGPU エラーがキャプチャされませんでした:", event.error.message);
console.error(
"WebGPU エラーがキャプチャされませんでした:",
event.error.message,
);

reportErrorToServer({
type: event.error.constructor.name,
message: event.error.message,
});
});

// ...
```

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- [WebGPU API](/ja/docs/Web/API/WebGPU_API)
- [WebGPU Error Handling best practices](https://toji.dev/webgpu-best-practices/error-handling)
Loading