• <bdo id='kuxrA'></bdo><ul id='kuxrA'></ul>
    <legend id='kuxrA'><style id='kuxrA'><dir id='kuxrA'><q id='kuxrA'></q></dir></style></legend>
        <tfoot id='kuxrA'></tfoot>

        <small id='kuxrA'></small><noframes id='kuxrA'>

      1. <i id='kuxrA'><tr id='kuxrA'><dt id='kuxrA'><q id='kuxrA'><span id='kuxrA'><b id='kuxrA'><form id='kuxrA'><ins id='kuxrA'></ins><ul id='kuxrA'></ul><sub id='kuxrA'></sub></form><legend id='kuxrA'></legend><bdo id='kuxrA'><pre id='kuxrA'><center id='kuxrA'></center></pre></bdo></b><th id='kuxrA'></th></span></q></dt></tr></i><div id='kuxrA'><tfoot id='kuxrA'></tfoot><dl id='kuxrA'><fieldset id='kuxrA'></fieldset></dl></div>

        在哪里可以找到 AWS-SDK for dynamodb 在 NodeJS 打字稿

        时间:2023-09-03

          <bdo id='K4wbZ'></bdo><ul id='K4wbZ'></ul>

          <small id='K4wbZ'></small><noframes id='K4wbZ'>

              <i id='K4wbZ'><tr id='K4wbZ'><dt id='K4wbZ'><q id='K4wbZ'><span id='K4wbZ'><b id='K4wbZ'><form id='K4wbZ'><ins id='K4wbZ'></ins><ul id='K4wbZ'></ul><sub id='K4wbZ'></sub></form><legend id='K4wbZ'></legend><bdo id='K4wbZ'><pre id='K4wbZ'><center id='K4wbZ'></center></pre></bdo></b><th id='K4wbZ'></th></span></q></dt></tr></i><div id='K4wbZ'><tfoot id='K4wbZ'></tfoot><dl id='K4wbZ'><fieldset id='K4wbZ'></fieldset></dl></div>

                • <tfoot id='K4wbZ'></tfoot>
                    <tbody id='K4wbZ'></tbody>
                  <legend id='K4wbZ'><style id='K4wbZ'><dir id='K4wbZ'><q id='K4wbZ'></q></dir></style></legend>
                  本文介绍了在哪里可以找到 AWS-SDK for dynamodb 在 NodeJS 打字稿中的所有异常类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试将一些数据插入 dynamodb,并且正如预期的那样,我得到了一个 ConditionalCheckFailedException.因此,我试图仅针对该场景捕获该异常,除此之外,我想为所有其他错误引发服务器错误.但是要添加类型,我无法在 aws-sdk 中找到 ConditionalCheckFailedException.

                  I am trying to insert some data into dynamodb, and as expected I am getting a ConditionalCheckFailedException. So I am trying to catch that exception for only that scenario, apart from that I want to throw server error for all other errors. But to add the type, I am not able to find the ConditionalCheckFailedException in aws-sdk.

                  这就是我想要做的.

                  // where to import this from   
                  try {
                     await AWS.putItem(params).promise()
                  } catch (e) {
                    if (e instanceof ConditionalCheckFailedException) { // unable to find this exception type in AWS SDK
                      throw new Error('create error')
                    } else {
                      throw new Error('server error')
                    }
                  }
                  

                  推荐答案

                  你可以使用下面的守卫来检查错误:

                  You can check the error by using the following guard instead:

                  if (e.code === 'ConditionalCheckFailedException') {
                  

                  请注意,instanceof 仅适用于类,不适用于接口.所以即使你有类型,如果它是一个接口,你也不能使用它,因为它依赖于某些原型检查.使用 err.code 属性更安全.

                  Note that instanceof only works on classes, not on interfaces. So even if you had the type, if it was an interface you couldn't use it because it relies on certain prototype checks. Using the err.code property is safer.

                  这篇关于在哪里可以找到 AWS-SDK for dynamodb 在 NodeJS 打字稿中的所有异常类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用“包含"进行搜索?使用 DynamoDB 下一篇:使用 NodeJS 将新对象附加到 DynamoDB 中的 JSON 数组

                  相关文章

                  最新文章

                  <small id='JQ27N'></small><noframes id='JQ27N'>

                  <i id='JQ27N'><tr id='JQ27N'><dt id='JQ27N'><q id='JQ27N'><span id='JQ27N'><b id='JQ27N'><form id='JQ27N'><ins id='JQ27N'></ins><ul id='JQ27N'></ul><sub id='JQ27N'></sub></form><legend id='JQ27N'></legend><bdo id='JQ27N'><pre id='JQ27N'><center id='JQ27N'></center></pre></bdo></b><th id='JQ27N'></th></span></q></dt></tr></i><div id='JQ27N'><tfoot id='JQ27N'></tfoot><dl id='JQ27N'><fieldset id='JQ27N'></fieldset></dl></div>

                    <tfoot id='JQ27N'></tfoot>
                    <legend id='JQ27N'><style id='JQ27N'><dir id='JQ27N'><q id='JQ27N'></q></dir></style></legend>
                      • <bdo id='JQ27N'></bdo><ul id='JQ27N'></ul>