Skip to content

Commit cd778a7

Browse files
committed
chore: rename isStringifiedUserErrorObject to isSerializedUserErrorObject
1 parent 1e062d9 commit cd778a7

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

meteor/server/api/rest/v1/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ koaRouter.use(bodyParser())
5151
function extractErrorCode(e: unknown): number {
5252
if (ClientAPI.isClientResponseError(e)) {
5353
return e.error.errorCode
54-
} else if (UserError.isStringifiedUserErrorObject(e) || e instanceof UserError) {
54+
} else if (UserError.isSerializedUserErrorObject(e) || e instanceof UserError) {
5555
return e.errorCode
5656
} else if ((e as Meteor.Error).error && typeof (e as Meteor.Error).error === 'number') {
5757
return (e as Meteor.Error).error as number
@@ -63,15 +63,15 @@ function extractErrorCode(e: unknown): number {
6363
function validateUserError(e: unknown): UserError | undefined {
6464
if (e instanceof UserError) {
6565
return e
66-
} else if (UserError.isStringifiedUserErrorObject(e)) {
66+
} else if (UserError.isSerializedUserErrorObject(e)) {
6767
return UserError.fromUnknown(e)
6868
}
6969
}
7070

7171
function extractErrorUserMessage(e: unknown): string {
7272
if (ClientAPI.isClientResponseError(e)) {
7373
return translateMessage(e.error.userMessage, interpollateTranslation)
74-
} else if (UserError.isStringifiedUserErrorObject(e) || e instanceof UserError) {
74+
} else if (UserError.isSerializedUserErrorObject(e) || e instanceof UserError) {
7575
return translateMessage(e.userMessage, interpollateTranslation)
7676
} else if ((e as Meteor.Error).reason && typeof (e as Meteor.Error).reason === 'string') {
7777
return (e as Meteor.Error).reason as string

packages/corelib/src/error.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class UserError extends Error {
180180
static fromUnknown(err: unknown, errorCode?: number): UserError {
181181
if (err instanceof UserError) return err
182182

183-
if (this.isStringifiedUserErrorObject(err)) {
183+
if (this.isSerializedUserErrorObject(err)) {
184184
return new UserError(err.rawError, err.key, err.userMessage, err.errorCode)
185185
}
186186
const err2 = err instanceof Error ? err : new Error(stringifyError(err))
@@ -202,7 +202,7 @@ export class UserError extends Error {
202202
return undefined
203203
}
204204

205-
if (this.isStringifiedUserErrorObject(p)) {
205+
if (this.isSerializedUserErrorObject(p)) {
206206
return new UserError(p.rawError, p.key, p.userMessage, p.errorCode)
207207
} else {
208208
return undefined
@@ -227,10 +227,10 @@ export class UserError extends Error {
227227
}
228228
static fromJSON(str: string): SerializedUserError | undefined {
229229
const o = JSON.parse(str)
230-
if (this.isStringifiedUserErrorObject(o)) return o
230+
if (this.isSerializedUserErrorObject(o)) return o
231231
return undefined
232232
}
233-
static isStringifiedUserErrorObject(o: unknown): o is SerializedUserError {
233+
static isSerializedUserErrorObject(o: unknown): o is SerializedUserError {
234234
if (!o || typeof o !== 'object') return false
235235
const errorObject = o as SerializedUserError
236236

packages/meteor-lib/src/api/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export namespace ClientAPI {
8080
export function isClientResponseError(res: unknown): res is ClientResponseError {
8181
const res0 = res as ClientResponseError
8282
return (
83-
!!res0 && typeof res0 === 'object' && 'error' in res0 && UserError.isStringifiedUserErrorObject(res0.error)
83+
!!res0 && typeof res0 === 'object' && 'error' in res0 && UserError.isSerializedUserErrorObject(res0.error)
8484
)
8585
}
8686
export function isClientResponseSuccess(res: unknown): res is ClientResponseSuccess<any> {

0 commit comments

Comments
 (0)