@lti-tool/core 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Formats an unknown error into a readable string message.
3
+ * Handles Error objects, strings, and other types safely.
4
+ *
5
+ * @param error - The error to format (can be Error, string, or any other type)
6
+ * @returns Formatted error message string
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * try {
11
+ * await riskyOperation();
12
+ * } catch (error) {
13
+ * throw new Error(`Operation failed: ${formatError(error)}`);
14
+ * }
15
+ * ```
16
+ */
17
+ export function formatError(error: unknown): string {
18
+ if (error instanceof Error) {
19
+ return error.message;
20
+ }
21
+ return String(error);
22
+ }