@archbase/core 4.0.19 → 4.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/dist/index.js CHANGED
@@ -3001,12 +3001,15 @@ function processErrorMessage(error) {
3001
3001
  if (error && error.response && error.response.status && error.response.status === 401 || error && error.status && error.status === 401) {
3002
3002
  return t("archbase:Usuário/senha não encontrados. Não autorizado.");
3003
3003
  }
3004
- if (error.response && error.response.data && error.response.data.apierror) {
3005
- msgErro = error.response.data.apierror.message;
3006
- if (error.response.data.apierror.subErrors) {
3004
+ const apiError = error?.response?.data?.apierror ?? error?.response?.data;
3005
+ const fieldErrorList = apiError?.subErrors ?? apiError?.fieldErrors;
3006
+ if (apiError && (fieldErrorList || apiError.message)) {
3007
+ msgErro = apiError.message;
3008
+ if (fieldErrorList) {
3007
3009
  msgErro = [];
3008
- error.response.data.apierror.subErrors.forEach((element) => {
3009
- msgErro.push(`(${element.field}) ${element.message}`);
3010
+ fieldErrorList.forEach((element) => {
3011
+ const fieldName = element.field ?? element.property;
3012
+ msgErro.push(`(${fieldName}) ${element.message}`);
3010
3013
  });
3011
3014
  }
3012
3015
  } else if (error.response && error.response.status && error.response.status === 404) {
@@ -3040,8 +3043,9 @@ function processErrorMessage(error) {
3040
3043
  }
3041
3044
  function processDetailErrorMessage(error) {
3042
3045
  let msgErro = "";
3043
- if (error.response && error.response.data && error.response.data.apierror) {
3044
- msgErro = error.response.data.apierror.debugMessage;
3046
+ const apiError = error?.response?.data?.apierror ?? error?.response?.data;
3047
+ if (apiError?.debugMessage) {
3048
+ msgErro = apiError.debugMessage;
3045
3049
  }
3046
3050
  return `${msgErro}`;
3047
3051
  }