Errors

Error response format มาตรฐาน:

{
  "error": {
    "code": "not_found",
    "message": "no ecu_model with code XYZ",
    "docs_url": "https://developers.smongrot.com/docs/errors"
  }
}

Error codes

HTTPCodeเกิดเมื่อแก้ยังไง
400bad_requestMissing/invalid parameterเช็ค required params ใน endpoint docs
401unauthorizedMissing/invalid/revoked keyดู Authentication
404not_foundPath หรือ resource ไม่มีเช็ค URL + ID
405method_not_allowedใช้ POST/PUT/DELETEv1 = GET only
429rate_limit_exceededเกินโควตาวันดู Rate limits
500internal_errorServer bugRetry, ถ้ายัง fail แจ้งเรา

HTTP status conventions

  • 2xx — success
  • 4xx — ผู้เรียกทำผิด (payload, auth, quota)
  • 5xx — server side issue (เราแก้เอง)

อย่า retry 4xx อัตโนมัติ — จะยังผิดเดิมทุกครั้ง (ยกเว้น 429 พร้อม Retry-After)

Retry 5xx ได้ — ใช้ exponential backoff (1s, 2s, 4s, 8s, max 60s)

ตัวอย่าง error responses

Missing ecu_code parameter

GET /v1/ecu-models/
HTTP/2 404
{ "error": { "code": "not_found", "message": "no route for /v1/ecu-models/" } }

Wrong key format

Authorization: Bearer wrong_prefix_key
HTTP/2 401
{ "error": { "code": "unauthorized", "message": "malformed key" } }

ECU code ที่ไม่มี

GET /v1/ecu-models/DOES-NOT-EXIST
HTTP/2 404
{ "error": { "code": "not_found", "message": "no ecu_model with code DOES-NOT-EXIST" } }

Reporting bugs

ถ้าเจอ error code ที่ไม่ documented หรือ 500 บ่อยๆ — email มาที่ hello@smongrot.com พร้อม:

  • Timestamp (UTC)
  • Full request (path + headers ยกเว้น API key)
  • Response body

หรือ open issue