@trpc/client 11.0.0-alpha-tmp-issues-5851-take-two.479 → 11.0.0-alpha-tmp-issues-5851-take-two.481
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/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/TRPCClientError.js +11 -8
- package/dist/TRPCClientError.mjs +12 -9
- package/dist/bundle-analysis.json +27 -27
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +1 -0
- package/dist/links/httpBatchLink.mjs +1 -0
- package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
- package/dist/links/httpBatchStreamLink.js +1 -0
- package/dist/links/httpBatchStreamLink.mjs +1 -0
- package/package.json +4 -4
- package/src/TRPCClientError.ts +15 -10
- package/src/links/httpBatchLink.ts +1 -0
- package/src/links/httpBatchStreamLink.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAElD,KAAK,eAAe,CAAC,WAAW,SAAS,qBAAqB,IAC5D,gBAAgB,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;AAC9C,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,iBAAiB;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;CACtC;AACD,MAAM,MAAM,mBAAmB,CAAC,WAAW,SAAS,qBAAqB,IACvE,mBAAmB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAgCpD,qBAAa,eAAe,CAAC,kBAAkB,SAAS,qBAAqB,CAC3E,SAAQ,KACR,YAAW,mBAAmB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAInE,SAAyB,KAAK,oBAAC;IAC/B,SAAgB,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,SAAgB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzE;;;OAGG;IACI,IAAI,sCAAC;gBAGV,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACvE,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;WAkBW,IAAI,CAAC,kBAAkB,SAAS,qBAAqB,EACjE,MAAM,EAAE,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EACtC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAO,GAC5C,eAAe,CAAC,kBAAkB,CAAC;CA2BvC"}
|
package/dist/TRPCClientError.js
CHANGED
|
@@ -11,6 +11,15 @@ function isTRPCClientError(cause) {
|
|
|
11
11
|
function isTRPCErrorResponse(obj) {
|
|
12
12
|
return unstableCoreDoNotImport.isObject(obj) && unstableCoreDoNotImport.isObject(obj['error']) && typeof obj['error']['code'] === 'number' && typeof obj['error']['message'] === 'string';
|
|
13
13
|
}
|
|
14
|
+
function getMessageFromUnknownError(err, fallback) {
|
|
15
|
+
if (typeof err === 'string') {
|
|
16
|
+
return err;
|
|
17
|
+
}
|
|
18
|
+
if (unstableCoreDoNotImport.isObject(err) && typeof err['message'] === 'string') {
|
|
19
|
+
return err['message'];
|
|
20
|
+
}
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
14
23
|
class TRPCClientError extends Error {
|
|
15
24
|
static from(_cause, opts = {}) {
|
|
16
25
|
const cause = _cause;
|
|
@@ -30,15 +39,9 @@ class TRPCClientError extends Error {
|
|
|
30
39
|
result: cause
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
return new TRPCClientError('Unknown error', {
|
|
35
|
-
...opts,
|
|
36
|
-
cause: cause
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return new TRPCClientError(cause.message, {
|
|
42
|
+
return new TRPCClientError(getMessageFromUnknownError(cause, 'Unknown error'), {
|
|
40
43
|
...opts,
|
|
41
|
-
cause:
|
|
44
|
+
cause: cause
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
constructor(message, opts){
|
package/dist/TRPCClientError.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject } from '@trpc/server/unstable-core-do-not-import';
|
|
2
2
|
|
|
3
3
|
function isTRPCClientError(cause) {
|
|
4
4
|
return cause instanceof TRPCClientError || /**
|
|
@@ -9,6 +9,15 @@ function isTRPCClientError(cause) {
|
|
|
9
9
|
function isTRPCErrorResponse(obj) {
|
|
10
10
|
return isObject(obj) && isObject(obj['error']) && typeof obj['error']['code'] === 'number' && typeof obj['error']['message'] === 'string';
|
|
11
11
|
}
|
|
12
|
+
function getMessageFromUnknownError(err, fallback) {
|
|
13
|
+
if (typeof err === 'string') {
|
|
14
|
+
return err;
|
|
15
|
+
}
|
|
16
|
+
if (isObject(err) && typeof err['message'] === 'string') {
|
|
17
|
+
return err['message'];
|
|
18
|
+
}
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
12
21
|
class TRPCClientError extends Error {
|
|
13
22
|
static from(_cause, opts = {}) {
|
|
14
23
|
const cause = _cause;
|
|
@@ -28,15 +37,9 @@ class TRPCClientError extends Error {
|
|
|
28
37
|
result: cause
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
return new TRPCClientError('Unknown error', {
|
|
33
|
-
...opts,
|
|
34
|
-
cause: cause
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return new TRPCClientError(cause.message, {
|
|
40
|
+
return new TRPCClientError(getMessageFromUnknownError(cause, 'Unknown error'), {
|
|
38
41
|
...opts,
|
|
39
|
-
cause:
|
|
42
|
+
cause: cause
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
constructor(message, opts){
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 25.
|
|
2
|
+
"bundleSize": 51133,
|
|
3
|
+
"bundleOrigSize": 68325,
|
|
4
|
+
"bundleReduction": 25.16,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink.ts",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
],
|
|
14
14
|
"removedExports": [],
|
|
15
15
|
"dependents": [],
|
|
16
|
-
"percent": 25.
|
|
16
|
+
"percent": 25.56,
|
|
17
17
|
"reduction": 10.22
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"id": "/src/links/httpBatchStreamLink.ts",
|
|
21
|
-
"size":
|
|
22
|
-
"origSize":
|
|
21
|
+
"size": 5913,
|
|
22
|
+
"origSize": 6116,
|
|
23
23
|
"renderedExports": [
|
|
24
24
|
"unstable_httpBatchStreamLink"
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 11.
|
|
29
|
-
"reduction": 3.
|
|
28
|
+
"percent": 11.56,
|
|
29
|
+
"reduction": 3.32
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "/src/links/loggerLink.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"removedExports": [],
|
|
39
39
|
"dependents": [],
|
|
40
|
-
"percent": 10.
|
|
40
|
+
"percent": 10.67,
|
|
41
41
|
"reduction": 18.48
|
|
42
42
|
},
|
|
43
43
|
{
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
"/src/links/httpBatchLink.ts",
|
|
53
53
|
"/src/links/httpBatchStreamLink.ts"
|
|
54
54
|
],
|
|
55
|
-
"percent":
|
|
55
|
+
"percent": 7.99,
|
|
56
56
|
"reduction": 5.64
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"id": "/src/links/httpBatchLink.ts",
|
|
60
|
-
"size":
|
|
61
|
-
"origSize":
|
|
60
|
+
"size": 3973,
|
|
61
|
+
"origSize": 4156,
|
|
62
62
|
"renderedExports": [
|
|
63
63
|
"httpBatchLink"
|
|
64
64
|
],
|
|
65
65
|
"removedExports": [],
|
|
66
66
|
"dependents": [],
|
|
67
|
-
"percent": 7.
|
|
68
|
-
"reduction": 4.
|
|
67
|
+
"percent": 7.77,
|
|
68
|
+
"reduction": 4.4
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"id": "/src/links/internals/httpUtils.ts",
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
],
|
|
84
84
|
"removedExports": [],
|
|
85
85
|
"dependents": [
|
|
86
|
-
"/src/links/httpBatchLink.ts",
|
|
87
86
|
"/src/links/httpLink.ts",
|
|
87
|
+
"/src/links/httpBatchLink.ts",
|
|
88
88
|
"/src/links/httpBatchStreamLink.ts",
|
|
89
89
|
"/src/links/httpSubscriptionLink.ts"
|
|
90
90
|
],
|
|
91
|
-
"percent": 7.
|
|
91
|
+
"percent": 7.18,
|
|
92
92
|
"reduction": 37.5
|
|
93
93
|
},
|
|
94
94
|
{
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
],
|
|
101
101
|
"removedExports": [],
|
|
102
102
|
"dependents": [],
|
|
103
|
-
"percent": 6.
|
|
103
|
+
"percent": 6.89,
|
|
104
104
|
"reduction": 6.13
|
|
105
105
|
},
|
|
106
106
|
{
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
],
|
|
113
113
|
"removedExports": [],
|
|
114
114
|
"dependents": [],
|
|
115
|
-
"percent": 6.
|
|
115
|
+
"percent": 6.23,
|
|
116
116
|
"reduction": 14.15
|
|
117
117
|
},
|
|
118
118
|
{
|
|
@@ -127,28 +127,28 @@
|
|
|
127
127
|
"/src/createTRPCUntypedClient.ts",
|
|
128
128
|
"/src/createTRPCClient.ts"
|
|
129
129
|
],
|
|
130
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.41,
|
|
131
131
|
"reduction": 46.78
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
134
|
"id": "/src/TRPCClientError.ts",
|
|
135
|
-
"size":
|
|
136
|
-
"origSize":
|
|
135
|
+
"size": 1940,
|
|
136
|
+
"origSize": 3555,
|
|
137
137
|
"renderedExports": [
|
|
138
138
|
"TRPCClientError"
|
|
139
139
|
],
|
|
140
140
|
"removedExports": [],
|
|
141
141
|
"dependents": [
|
|
142
142
|
"/src/index.ts",
|
|
143
|
-
"/src/links/httpBatchLink.ts",
|
|
144
143
|
"/src/links/httpLink.ts",
|
|
144
|
+
"/src/links/httpBatchLink.ts",
|
|
145
145
|
"/src/links/wsLink.ts",
|
|
146
146
|
"/src/links/httpBatchStreamLink.ts",
|
|
147
147
|
"/src/links/httpSubscriptionLink.ts",
|
|
148
148
|
"/src/internals/TRPCUntypedClient.ts"
|
|
149
149
|
],
|
|
150
|
-
"percent": 3.
|
|
151
|
-
"reduction": 45.
|
|
150
|
+
"percent": 3.79,
|
|
151
|
+
"reduction": 45.43
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
"id": "/src/createTRPCClient.ts",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"dependents": [
|
|
165
165
|
"/src/index.ts"
|
|
166
166
|
],
|
|
167
|
-
"percent": 2.
|
|
167
|
+
"percent": 2.32,
|
|
168
168
|
"reduction": 73.19
|
|
169
169
|
},
|
|
170
170
|
{
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
],
|
|
192
192
|
"removedExports": [],
|
|
193
193
|
"dependents": [],
|
|
194
|
-
"percent": 1.
|
|
194
|
+
"percent": 1.19,
|
|
195
195
|
"reduction": 44.95
|
|
196
196
|
},
|
|
197
197
|
{
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"dependents": [
|
|
206
206
|
"/src/unstable-internals.ts"
|
|
207
207
|
],
|
|
208
|
-
"percent": 1.
|
|
208
|
+
"percent": 1.1,
|
|
209
209
|
"reduction": 66.75
|
|
210
210
|
},
|
|
211
211
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAmHnB"}
|
|
@@ -34,6 +34,7 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
34
34
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
35
35
|
const inputs = batchOps.map((op)=>op.input);
|
|
36
36
|
const ac = httpUtils.mergeAbortSignals(batchOps);
|
|
37
|
+
ac.signal.throwIfAborted();
|
|
37
38
|
const res = await httpUtils.jsonHttpRequester({
|
|
38
39
|
...resolvedOpts,
|
|
39
40
|
path,
|
|
@@ -32,6 +32,7 @@ import { resolveHTTPLinkOptions, getUrl, mergeAbortSignals, jsonHttpRequester }
|
|
|
32
32
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
33
33
|
const inputs = batchOps.map((op)=>op.input);
|
|
34
34
|
const ac = mergeAbortSignals(batchOps);
|
|
35
|
+
ac.signal.throwIfAborted();
|
|
35
36
|
const res = await jsonHttpRequester({
|
|
36
37
|
...resolvedOpts,
|
|
37
38
|
path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,SAAS,EACpE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,SAAS,EACpE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,CA8JnB"}
|
|
@@ -38,6 +38,7 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
38
38
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
39
39
|
const inputs = batchOps.map((op)=>op.input);
|
|
40
40
|
const ac = httpUtils.mergeAbortSignals(batchOps);
|
|
41
|
+
ac.signal.throwIfAborted();
|
|
41
42
|
const responsePromise = httpUtils.fetchHTTPResponse({
|
|
42
43
|
...resolvedOpts,
|
|
43
44
|
signal: ac.signal,
|
|
@@ -36,6 +36,7 @@ import { resolveHTTPLinkOptions, getUrl, mergeAbortSignals, fetchHTTPResponse, g
|
|
|
36
36
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
37
37
|
const inputs = batchOps.map((op)=>op.input);
|
|
38
38
|
const ac = mergeAbortSignals(batchOps);
|
|
39
|
+
ac.signal.throwIfAborted();
|
|
39
40
|
const responsePromise = fetchHTTPResponse({
|
|
40
41
|
...resolvedOpts,
|
|
41
42
|
signal: ac.signal,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-issues-5851-take-two.
|
|
3
|
+
"version": "11.0.0-alpha-tmp-issues-5851-take-two.481+521a58480",
|
|
4
4
|
"description": "The tRPC client library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"!**/*.test.*"
|
|
77
77
|
],
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.
|
|
79
|
+
"@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.481+521a58480"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.
|
|
82
|
+
"@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.481+521a58480",
|
|
83
83
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
84
84
|
"@types/node": "^20.10.0",
|
|
85
85
|
"eslint": "^8.56.0",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"funding": [
|
|
97
97
|
"https://trpc.io/sponsor"
|
|
98
98
|
],
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "521a58480a40f3448c788cf38297f0fab5d51558"
|
|
100
100
|
}
|
package/src/TRPCClientError.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
TRPCErrorResponse,
|
|
6
6
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
7
7
|
import {
|
|
8
|
-
getCauseFromUnknown,
|
|
9
8
|
isObject,
|
|
10
9
|
type DefaultErrorShape,
|
|
11
10
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
@@ -40,6 +39,16 @@ function isTRPCErrorResponse(obj: unknown): obj is TRPCErrorResponse<any> {
|
|
|
40
39
|
);
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
function getMessageFromUnknownError(err: unknown, fallback: string): string {
|
|
43
|
+
if (typeof err === 'string') {
|
|
44
|
+
return err;
|
|
45
|
+
}
|
|
46
|
+
if (isObject(err) && typeof err['message'] === 'string') {
|
|
47
|
+
return err['message'];
|
|
48
|
+
}
|
|
49
|
+
return fallback;
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
export class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
44
53
|
extends Error
|
|
45
54
|
implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>>
|
|
@@ -102,16 +111,12 @@ export class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
|
102
111
|
result: cause,
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
return new TRPCClientError(
|
|
115
|
+
getMessageFromUnknownError(cause, 'Unknown error'),
|
|
116
|
+
{
|
|
107
117
|
...opts,
|
|
108
118
|
cause: cause as any,
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return new TRPCClientError(cause.message, {
|
|
113
|
-
...opts,
|
|
114
|
-
cause: getCauseFromUnknown(cause),
|
|
115
|
-
});
|
|
119
|
+
},
|
|
120
|
+
);
|
|
116
121
|
}
|
|
117
122
|
}
|