trpc-browser
Advanced tools
Comparing version
@@ -6,2 +6,3 @@ "use strict"; | ||
const observable_1 = require("@trpc/server/observable"); | ||
const shared_1 = require("@trpc/server/shared"); | ||
const trpcMessage_1 = require("../shared/trpcMessage"); | ||
@@ -52,3 +53,4 @@ const errors_1 = require("./errors"); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
error: router.getErrorShape({ | ||
error: (0, shared_1.getErrorShape)({ | ||
config: router._def._config, | ||
error, | ||
@@ -55,0 +57,0 @@ type: method, |
@@ -6,22 +6,20 @@ "use strict"; | ||
function getErrorFromUnknown(cause) { | ||
if (cause instanceof Error && cause.name === 'TRPCError') { | ||
return cause; | ||
} | ||
let errorCause = undefined; | ||
let stack = undefined; | ||
if (cause instanceof Error) { | ||
errorCause = cause; | ||
stack = cause.stack; | ||
if (cause.name === 'TRPCError') { | ||
return cause; | ||
} | ||
const error = new server_1.TRPCError({ | ||
message: 'Internal server error', | ||
code: 'INTERNAL_SERVER_ERROR', | ||
cause: cause, | ||
}); | ||
error.stack = cause.stack; | ||
return error; | ||
} | ||
const error = new server_1.TRPCError({ | ||
return new server_1.TRPCError({ | ||
message: 'Internal server error', | ||
code: 'INTERNAL_SERVER_ERROR', | ||
cause: errorCause, | ||
}); | ||
if (stack) { | ||
error.stack = stack; | ||
} | ||
return error; | ||
} | ||
exports.getErrorFromUnknown = getErrorFromUnknown; | ||
//# sourceMappingURL=errors.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
const observable_1 = require("@trpc/server/observable"); | ||
const shared_1 = require("@trpc/server/shared"); | ||
const constants_1 = require("../shared/constants"); | ||
@@ -57,3 +58,4 @@ const trpcMessage_1 = require("../shared/trpcMessage"); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
error: router.getErrorShape({ | ||
error: (0, shared_1.getErrorShape)({ | ||
config: router._def._config, | ||
error, | ||
@@ -60,0 +62,0 @@ type: method, |
@@ -14,2 +14,3 @@ "use strict"; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const input = runtime.transformer.serialize(op.input); | ||
@@ -28,5 +29,3 @@ const onDisconnect = () => { | ||
if ('error' in trpc) { | ||
const error = runtime.transformer.deserialize(trpc.error); | ||
observer.error(client_1.TRPCClientError.from(Object.assign(Object.assign({}, trpc), { error }))); | ||
return; | ||
return observer.error(client_1.TRPCClientError.from(trpc)); | ||
} | ||
@@ -36,2 +35,3 @@ observer.next({ | ||
type: 'data', | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
data: runtime.transformer.deserialize(trpc.result.data), | ||
@@ -51,2 +51,3 @@ })), | ||
method: type, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
params: { path, input }, | ||
@@ -53,0 +54,0 @@ }, |
{ | ||
"name": "trpc-browser", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "tRPC adapters and links for everywhere in the browser", | ||
@@ -5,0 +5,0 @@ "author": "Janek Rahrt <janek.rahrt@me.com>, James Berry <jb@jamesbe.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74044
0.42%774
0.39%