@axium/client 0.19.4 → 0.19.6
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.
- package/assets/styles.css +1 -0
- package/dist/requests.js +2 -1
- package/lib/toast.ts +3 -0
- package/package.json +1 -1
package/assets/styles.css
CHANGED
package/dist/requests.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $API } from '@axium/core/api';
|
|
2
|
+
import { errorText } from '@axium/core/io';
|
|
2
3
|
import { prettifyError } from 'zod';
|
|
3
4
|
// @ts-expect-error 2339
|
|
4
5
|
BigInt.prototype.toJSON = function () {
|
|
@@ -79,6 +80,6 @@ export async function fetchAPI(method, endpoint, data, ...params) {
|
|
|
79
80
|
return Output.parse(json);
|
|
80
81
|
}
|
|
81
82
|
catch (e) {
|
|
82
|
-
throw `${method} ${endpoint}:\n${
|
|
83
|
+
throw `${method} ${endpoint}:\n${errorText(e)}`;
|
|
83
84
|
}
|
|
84
85
|
}
|
package/lib/toast.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { text } from '@axium/client/locales';
|
|
|
3
3
|
import { animate, onAnimationEnd } from '@axium/client/gui';
|
|
4
4
|
import Icon from './Icon.svelte';
|
|
5
5
|
import { mount } from 'svelte';
|
|
6
|
+
import { $ZodError, prettifyError } from 'zod/v4/core';
|
|
6
7
|
|
|
7
8
|
const list = document.querySelector<HTMLDivElement>('#toasts')!;
|
|
8
9
|
|
|
@@ -22,6 +23,8 @@ const durationMultiplier = {
|
|
|
22
23
|
} as Record<ToastType, number>;
|
|
23
24
|
|
|
24
25
|
export async function toast(type: ToastType, message: any): Promise<void> {
|
|
26
|
+
if (message instanceof $ZodError) console.error('[toast]', prettifyError(message));
|
|
27
|
+
else if (message instanceof Error) console.error('[toast]', message);
|
|
25
28
|
const text = errorText(message);
|
|
26
29
|
|
|
27
30
|
const toast = document.createElement('div');
|