Skip to content

アクセス権絡みのエラーが発生した時もKintoneRestAPIError#errorsが欲しい #13

@the-red

Description

@the-red

Package(対象パッケージ)

  • @kintone/rest-api-client

Why(なぜ)

update権限がないレコードに対してupdateRecord()した場合など、
アクセス権に問題があるときは403エラーが返ってきますが、
エラーオブジェクトにerrorsmessageもないため、エラー原因をぱっと見で確認するのが難しいです。
(エンジニアなら分かっても、一般ユーザーには分からないです。)

{
  "name": "KintoneRestAPIError",
  "id": "veh9IwUXQwn0wstIvhrv",
  "code": "CB_NO02",
  "status": 403,
  "headers": {
    "cache-control": "no-cache, no-store, must-revalidate",
    "connection": "keep-alive",
    "content-encoding": "gzip",
    "content-type": "application/json;charset=utf-8",
    "date": "Wed, 02 Dec 2020 02:03:51 GMT",
    "server": "nginx",
    "strict-transport-security": "max-age=315360000; includeSubDomains; preload;",
    "transfer-encoding": "chunked",
    "vary": "Accept-Encoding",
    "x-concurrencylimit-limit": "100",
    "x-concurrencylimit-running": "1",
    "x-content-type-options": "nosniff",
    "x-cybozu-error": "GAIA_BR01",
    "x-frame-options": "SAMEORIGIN",
    "x-ua-compatible": "IE=Edge",
    "x-xss-protection": "1; mode=block"
  }
}

kintoneからのレスポンスに、そもそもerrors相当のものがないのだと思いますが、
せっかくSDKでラップしてもらっているので、
kintone APIエラーメッセージが気が利かない部分も吸収していただけると助かります。

エラーが起きた時、ユーザーにerrorsの内容をアラートで表示してあげることが多いので、
ユーザーに日本語でエラーを見せるには、
「403の時はアクセス権がありませんという文章を出す」みたいなロジックが必要です。
自分で実装するよりは、SDK側で対応してもらえると有り難いのです。

What(何を)

ちょっとした日本語で良いので、
code, statusに対応するメッセージが出ると良いですね。

アクセス権以外にもメッセージ無しのエラーはあるかもしれませんが、未確認です。

{
  "name": "KintoneRestAPIError",
  "id": "veh9IwUXQwn0wstIvhrv",
  "code": "CB_NO02",
  "errors": {
    "message": "アクセス権がありません。"
  },
  "status": 403,
  "headers": {
    "cache-control": "no-cache, no-store, must-revalidate",
    "connection": "keep-alive",
    "content-encoding": "gzip",
    "content-type": "application/json;charset=utf-8",
    "date": "Wed, 02 Dec 2020 02:03:51 GMT",
    "server": "nginx",
    "strict-transport-security": "max-age=315360000; includeSubDomains; preload;",
    "transfer-encoding": "chunked",
    "vary": "Accept-Encoding",
    "x-concurrencylimit-limit": "100",
    "x-concurrencylimit-running": "1",
    "x-content-type-options": "nosniff",
    "x-cybozu-error": "GAIA_BR01",
    "x-frame-options": "SAMEORIGIN",
    "x-ua-compatible": "IE=Edge",
    "x-xss-protection": "1; mode=block"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions