Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK 内部 extractError 会屏蔽接口的错误信息,导致难以排错 #187

Open
nodejh opened this issue Aug 29, 2019 · 0 comments
Open

Comments

@nodejh
Copy link

nodejh commented Aug 29, 2019

lib/service_interface/json.js 里面的 extractError 方法会导致一些错误,无法展示给用户。

源码:

  extractError: function extractError(resp) {
    var error = {};
    var httpResponse = resp.httpResponse;

    if (httpResponse.body.length > 0) {
      var e = JSON.parse(httpResponse.body.toString());
      if (e.__type || e.code || e.Code) {
        error.code = (e.__type || e.code || e.Code).split('#').pop();
      } else {
        error.code = 'UnknownError';
      }
      if (error.code === 'RequestEntityTooLarge') {
        error.message = 'Request body must be less than 1 MB';
      } else {
        error.message = (e.message || e.Message || null);
      }
    } else {
      error.code = httpResponse.statusCode;
      error.message = null;
    }

    resp.error = ALY.util.error(new Error(), error);
  },

而有的错误不是 codeCode,而是 errorCode,如 SLS 接口的错误:

{"errorCode":"ParameterInvalid","errorMessage":"ErrorType:ColumnNotExists.ErrorPosition,line:1633886764,column:1.ErrorMessage:line 1:109: Column 'count' cannot be resolved;please add the column in the index attribute"}

这就导致了,该错误不会展示给用户,而是 SDK 抛出 UnknownError 异常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant