DE 

//Cloudogu EcoSystem Docs

Guidelines for handling errors in the Baseline tool.

This document describes the procedure how specific error messages are mapped in Baseline.

1. struct WithCode serves as communication medium

WithCode is a separate error type (struct) and is used within the Baseline backend to pass information to the end user in case of an error. information to the end user in case of an error. Thereby the formulation and structure of the existing errors and their error codes and texts. All error codes can be found in the errorMessages.go file in the customerror package. package. There is also the function WriteErrorWithCode, which evaluates the WithCode error and sends it as response to the frontend. In this function the error codes as well as variables to be inserted into the error messages (e.g. the name of a baseline or the name of a file) of the response are written. or the name of a file) are added to the response. The frontend can then evaluate them.

2. handling of errors in the frontend

Each part of the frontend that takes care of handling these errors handles them in two different ways.

  1. it tries if a translation of the error named specific_backend_errors.<error-code> has been defined in the translation file. If this is the case, this translation of the error is taken and if necessary existing variables, which were transmitted by the backend, will be inserted. 2.
  2. if this translation is not present, a fallback error message is returned.

To map this logic, the function errorMessage(options: {error: ErrorWithCode,fallbackMsgKey: string}) was created.