Skip to content

Commit

Permalink
Update ReactController.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanDoggie committed Nov 30, 2021
1 parent 592ae74 commit 507d91e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/ReactController/ReactController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public class ReactController: RouteCollection {
try $0.evaluateScript(String(contentsOf: serverScript))

if let exception = $0.exception {

#if DEBUG

print("Error message:", exception["message"].stringValue ?? "")
print("stack:", exception["stack"].stringValue ?? "")

#endif

throw Error(message: exception["message"].stringValue)
}
}
Expand Down Expand Up @@ -101,6 +109,14 @@ extension ReactController {
let result = context.global["render"].call(withArguments: arguments.map { JSObject(json: $0, in: context) })

if let exception = context.exception {

#if DEBUG

print("Error message:", exception["message"].stringValue ?? "")
print("stack:", exception["stack"].stringValue ?? "")

#endif

throw Abort(.internalServerError, reason: exception["message"].stringValue)
}

Expand Down

0 comments on commit 507d91e

Please sign in to comment.