package ppx_platform

Build not checked
  1. Overview
  2. Docs
Platform-specific code for native and Melange builds

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ppx_platform-0.1.0.tbz
sha256=bb9987a34d52ffbc501b6c86a759dfe0078a92791bf6424f7c5fca4520289906
sha512=41ad7ffb121061580f50cbcd225c7493468b7ba37008dcdc2917d9ba3299069311c68a32022d311af808c24451335c6ab85be06ddeccdc68011de4e9277c4d8f

doc/src/ppx_platform.runtime/ppx_platform_runtime.ml.html

Source file ppx_platform_runtime.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
exception Impossible_in_ssr of string

let fail_impossible_action_in_ssr fn =
  let backtrace = Printexc.get_callstack 8 in
  let raw_callstack = Printexc.raw_backtrace_to_string backtrace in
  let () =
    Printf.printf
      {|'%s' should only run on the client. Make sure you aren't accidentally calling this function in a server-side context.

Here's the raw callstack:

%s
|}
      fn raw_callstack
  in
  raise (Impossible_in_ssr (Printf.sprintf {|'%s' shouldn't run on the server|} fn))