File tree Expand file tree Collapse file tree
packages/meteor-lib/src/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,12 +48,18 @@ export namespace ClientAPI {
4848 /** On error, provide a human-readable error message */
4949 error : UserError
5050 }
51+
5152 /**
52- * Used to reply to the user that the action didn't succeed (but it's not bad enough to log it as an error)
53- * @param errorMessage
53+ * Returns a `ClientResponseError` object from a given `UserError`.
54+ *
55+ * If no `errorCode` is provided, it defaults to `error.errorCode` which is 500 when not specified.
56+ *
57+ * @param error - The `UserError` instance containing error details.
58+ * @param errorCode - An optional error code to override the default `error.errorCode`.
59+ * @returns A `ClientResponseError` object containing the error and the resolved error code.
5460 */
5561 export function responseError ( error : UserError , errorCode ?: number ) : ClientResponseError {
56- return { error, errorCode : errorCode ?? 500 }
62+ return { error, errorCode : errorCode ?? error . errorCode }
5763 }
5864 export interface ClientResponseSuccess < Result > {
5965 /** On success, return success code (by default, use 200) */
You can’t perform that action at this time.
0 commit comments