fix: Show toast on clipboard errors
This commit is contained in:
@@ -5,10 +5,17 @@
|
||||
* @param {string} text text to be written to the clipboard
|
||||
* @throws {Error} unable to copy text to clipboard
|
||||
*/
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
|
||||
export const copyTextToClipboard = async text => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch (error) {
|
||||
// TODO: show localized error message
|
||||
emitter.emit(
|
||||
'newToastMessage',
|
||||
'Network Error: Unable to copy text to clipboard.'
|
||||
);
|
||||
throw new Error(`Unable to copy text to clipboard: ${error.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user