Booking widget errors
How MedosBooking reports failures — config mistakes that throw from init(), start-up failures that reach onError, and in-flow errors it handles itself.
Failures split three ways, and only one of them reaches onError.
| What went wrong | How you see it | Example |
|---|---|---|
| Bad config | init() throws synchronously | "API key is required" |
| Widget can't start | onError(error) | Workspace lookup rejected the key |
| Something failed mid-flow | The widget's own inline error UI | A wrong OTP code, a rejected booking |
Config mistakes throw
These are raised synchronously by init(), so catch them with try/catch —
onError will never see them:
| Thrown message | Cause |
|---|---|
API key is required | No apiKey passed. |
containerId is required for inline mode | Inline mode without a container. |
Container with id "X" not found | Inline mode, missing DOM node. |
try {
MedosBooking.init({ apiKey: "mk_...", mode: "inline", containerId: "book" });
} catch (err) {
console.error("Medos Booking failed to start:", err);
}Start-up failures call onError
What reaches onError is the
workspace-load or session-exchange failure, carrying the API's own message. The
widget renders its own error UI either way.
In-flow failures stay inside the widget
A failed verification code or a rejected booking shows the widget's own inline
error UI without calling onError.
A script that fails to load
If the script tag itself fails to load — a Content Security Policy that doesn't
allow widgets.medos.one, an ad blocker, a network error — then
window.MedosBooking is never defined and calling init() throws a
TypeError on undefined. Check the Network tab before debugging your config.
For more symptoms and fixes, see Troubleshooting.