API
Error
Setiap kode error yang dikembalikan API, lengkap dengan status HTTP, pesan, dan cara mengatasinya.
Setiap error punya bentuk yang sama. Periksa error.code di kodemu; pesannya untuk manusia dan bisa berubah.
{
"error": { "code": "record_changed", "message": "The record changed. Reload it before saving." },
"meta": { "request_id": "3L3NP3J4G546CPCD6HAIMKRCM6", "response_time": 1 }
} Detail internal tidak pernah muncul di error. Kirim request_id bersama laporan bug agar bisa dicari di log server. Kolom Pesan menampilkan teks asli dari API, dalam bahasa Inggris.
Error request
| Status | Code | Pesan | Yang perlu dilakukan |
|---|---|---|---|
| 400 | invalid_input | Check the submitted values. | Perbaiki body, query, atau tipe value. Field wajib harus ada. |
| 400 | workspace_required | Send the workspace in the X-Workspace-ID header or use a workspace path. | Pakai path dengan :workspace atau kirim X-Workspace-ID. |
| 404 | not_found | The requested resource is unavailable. | Periksa ID. Kamu juga mendapat ini untuk hal yang tidak boleh kamu lihat. |
Error login dan izin
| Status | Code | Pesan | Yang perlu dilakukan |
|---|---|---|---|
| 401 | authentication_required | Authentication is required or credentials are invalid. | Kirim satu token yang valid. Login ulang jika sudah kedaluwarsa. |
| 403 | access_denied | You do not have permission to perform this action. | Minta owner memberi peran dengan akses ini. |
| 403 | incorrect_password | The current password is incorrect. | Periksa password saat ini ketika menggantinya. |
| 429 | rate_limited | Too many requests. Try again later. | Tunggu sesuai detik Retry-After, lalu coba lagi. |
Error konflik
| Status | Code | Pesan | Yang perlu dilakukan |
|---|---|---|---|
| 409 | already_exists | A conflicting resource or value already exists. | Nilai unik sudah dipakai. Gunakan nilai lain. |
| 409 | ambiguous_lookup | The lookup key matches more than one record. | Jadikan field lookup unik. |
| 409 | schema_changed | The schema changed. Reload it before retrying. | Baca ulang koleksi, lalu coba lagi. |
| 409 | schema_dependency | Remove dependent indexes or lookups before changing field storage. | Hapus index atau lookup itu dulu. |
| 409 | schema_requires_empty_collection | This schema change requires an empty collection. | Kosongkan koleksi atau buat field baru sebagai gantinya. |
| 409 | index_requires_unique_values | Resolve duplicate values before creating a unique index. | Hapus duplikat, lalu tambahkan index. |
| 409 | workspace_not_empty | The workspace still contains data. Confirm to delete everything. | Konfirmasi penghapusan, atau kosongkan workspace dulu. |
| 412 | record_changed | The record changed. Reload it before saving. | Baca record untuk mendapat ETag baru, lalu coba lagi. |
| 412 | metadata_changed | The appearance changed. Reload it before saving. | Muat ulang pengaturan koleksi, lalu simpan lagi. |
Error server
| Status | Code | Pesan | Yang perlu dilakukan |
|---|---|---|---|
| 500 | internal_error | The request could not be completed. | Coba sekali lagi. Jika berulang, laporkan dengan request_id. |
| 503 | setup_required | Complete installation setup before using this service. | Klaim instalasi di Studio dulu. |
| 503 | core_not_initialized | The service is not ready. | Tunggu sebentar setelah startup, lalu coba lagi. |
| 503 | operation_unavailable | This operation is currently unavailable. | Fiturnya mati atau tidak didukung di database ini. |
Menangani error di kode
const res = await fetch(url, options);
if (!res.ok) {
const { error, meta } = await res.json();
if (error.code === 'record_changed') {
// read the record again and retry
}
throw new Error(`${error.code}: ${error.message} (request ${meta.request_id})`);
} if res.StatusCode >= 400 {
var out struct {
Error struct{ Code, Message string } `json:"error"`
Meta struct {
RequestID string `json:"request_id"`
} `json:"meta"`
}
json.NewDecoder(res.Body).Decode(&out)
return fmt.Errorf("%s: %s (request %s)", out.Error.Code, out.Error.Message, out.Meta.RequestID)
} if not res.ok:
body = res.json()
error, meta = body["error"], body["meta"]
raise RuntimeError(f"{error['code']}: {error['message']} (request {meta['request_id']})")