velocious 1.0.444 → 1.0.445

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "build/bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.444",
6
+ "version": "1.0.445",
7
7
  "main": "build/index.js",
8
8
  "types": "build/index.d.ts",
9
9
  "files": [
@@ -218,6 +218,14 @@ function frontendModelClientMessageForError(error) {
218
218
  return error.message
219
219
  }
220
220
 
221
+ // Validation failures are expected user-flow errors. Always forward the
222
+ // validation summary so the client shows the real reason (e.g. "Name can't
223
+ // be blank") instead of the generic "Request failed." message, regardless of
224
+ // whether the raising code also attached error.velocious metadata.
225
+ if (error instanceof ValidationError) {
226
+ return error.message
227
+ }
228
+
221
229
  if (frontendModelErrorHasVelociousMetadata(error) && error instanceof Error) {
222
230
  return error.message
223
231
  }
@@ -2827,6 +2835,24 @@ export default class FrontendModelController extends Controller {
2827
2835
  model: resolvedModel,
2828
2836
  requestId
2829
2837
  }])
2838
+
2839
+ // Surface genuinely unexpected backend failures on the framework-error
2840
+ // channel so process-level bug reporters capture them, instead of the
2841
+ // controller silently swallowing them behind the generic "Request
2842
+ // failed." client message. Developer-annotated user-flow errors
2843
+ // (`error.velocious` metadata — handled by the early return above),
2844
+ // validation errors, and deliberately client-safe VelociousErrors are
2845
+ // expected and must NOT be reported as framework errors.
2846
+ if (!(error instanceof ValidationError) && !(error instanceof VelociousError && error.safeToExpose)) {
2847
+ const errorPayload = {
2848
+ context: {action, commandType, frontendModelEndpoint: true, model: resolvedModel, requestId},
2849
+ error: error instanceof Error ? error : new Error(String(error)),
2850
+ request: this.getRequest()
2851
+ }
2852
+
2853
+ this.getConfiguration().getErrorEvents().emit("framework-error", errorPayload)
2854
+ this.getConfiguration().getErrorEvents().emit("all-error", {...errorPayload, errorType: "framework-error"})
2855
+ }
2830
2856
  }
2831
2857
 
2832
2858
  /**
@@ -3967,7 +3967,7 @@ export default class FrontendModelBase {
3967
3967
 
3968
3968
  const error = /**
3969
3969
  * Narrows the runtime value to the documented type.
3970
- @type {Error & {velocious?: Record<string, ?>, errorType?: string, validationErrors?: Record<string, ?>}} */ (new Error(errorMessage))
3970
+ @type {Error & {velocious?: Record<string, ?>, errorType?: string, validationErrors?: Record<string, ?>, debugErrorClass?: string, debugBacktrace?: string[]}} */ (new Error(errorMessage))
3971
3971
  if (response.velocious && typeof response.velocious === "object") {
3972
3972
  error.velocious = response.velocious
3973
3973
  }
@@ -3977,6 +3977,16 @@ export default class FrontendModelBase {
3977
3977
  if (response.validationErrors && typeof response.validationErrors === "object") {
3978
3978
  error.validationErrors = response.validationErrors
3979
3979
  }
3980
+ // Forward server-provided debug detail (included only when the backend
3981
+ // deems the requester allowed to see it, e.g. an admin) so callers can
3982
+ // render the real error class and stack trace instead of the generic
3983
+ // client-safe message.
3984
+ if (typeof response.debugErrorClass === "string") {
3985
+ error.debugErrorClass = response.debugErrorClass
3986
+ }
3987
+ if (Array.isArray(response.debugBacktrace)) {
3988
+ error.debugBacktrace = response.debugBacktrace
3989
+ }
3980
3990
  throw error
3981
3991
  }
3982
3992