AOSSIE-Org / AOSSIE-Org/SocialShareButton

Improvement: Add try-catch blocks for better error handling in social-share-button.js

オープン
#132 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
25
フォーク
64
平均マージ
2日 11時間
マージ済み PR(30日)
1

説明

## Overview

This issue tracks the addition of try-catch blocks in `src/social-share-button.js` to improve error handling and resilience. Adding defensive error handling in key methods ensures that unexpected failures are caught and surfaced appropriately, rather than silently failing or causing unhandled exceptions.

---

## Try-catch blocks to add

### 1. `createButton()` → `document.querySelector()`
`querySelector()` throws a `SyntaxError` when passed an invalid CSS selector string. Since the selector is user-supplied via `options.container`, a try-catch here is appropriate defensive programming.

### 2. `fallbackCopy()` → rename `_err` → `error` and add logging
The existing catch block silently swallows errors. Binding the error variable and logging it through the debug-gated `_debugWarn()` helper is a valid improvement.

---

## Acceptance Criteria

- [ ] Add try-catch in `createButton()` around `document.querySelector()` with `_debugWarn` logging
- [ ] Update the `fallbackCopy()` catch block to bind the error variable and log it via `_debugWarn()`

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。