Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ErrorResponse Class Reference

Helper class for generating RFC 9457 compliant error responses. More...

#include <mitkErrorResponse.h>

Public Types

using Json = nlohmann::json
 

Static Public Member Functions

static Json Create (const std::string &code, const std::string &title, const std::string &detail, int status, const std::string &instance="")
 Create an RFC 9457 error response. More...
 
static Json NodeNotFound (const std::string &uid, const std::string &instance="")
 Create a "Node not found" error response. More...
 
static Json PropertyNotFound (const std::string &propertyKey, const std::string &nodeUid, const std::string &instance="")
 Create a "Property not found" error response. More...
 
static Json DataStorageNotAvailable (const std::string &instance="")
 Create a "DataStorage not available" error response. More...
 
static Json InvalidRequest (const std::string &detail, const std::string &instance="")
 Create an "Invalid request" error response. More...
 
static Json InternalError (const std::string &detail, const std::string &instance="")
 Create an "Internal error" response. More...
 
static Json PropertyProtected (const std::string &propertyKey, const std::string &instance="")
 Create a "Property protected" error response. More...
 
static Json NodeHasChildren (int childrenCount, const std::string &instance="")
 Create a "Node has children" error response. More...
 
static Json NoData (const std::string &nodeUid, const std::string &instance="")
 Create a "No data" error response. More...
 
static Json NoGeometry (const std::string &nodeUid, const std::string &instance="")
 Create a "No geometry" error response. More...
 
static Json RenderingError (const std::string &detail, const std::string &instance="")
 Create a "Rendering error" error response. More...
 
static Json CircularHierarchyReference (const std::string &instance="")
 Create a "Circular hierarchy reference" error response. More...
 
static Json UnsupportedFormat (const std::string &detail, const std::string &instance="")
 Create an "Unsupported format" error response. More...
 
static Json SerializationError (const std::string &detail, const std::string &instance="")
 Create a "Serialization error" error response. More...
 
static Json FileNotFound (const std::string &filePath, const std::string &instance="")
 Create a "File not found" error response. More...
 
static Json FileReadError (const std::string &filePath, const std::string &detail, const std::string &instance="")
 Create a "File read error" error response. More...
 
static Json TransferModeNotAvailable (const std::string &requestedMode, const std::vector< std::string > &availableModes, const std::string &instance="")
 Create a "Transfer mode not available" error response. More...
 
static Json AccessDenied (const std::string &detail, const std::string &instance="")
 Create an "Access denied" error response. More...
 
static Json Unauthorized (const std::string &detail, const std::string &instance="")
 Create an "Unauthorized" error response. More...
 
static Json RateLimitExceeded (int retryAfterSeconds, const std::string &instance="")
 Create a "Rate limit exceeded" error response. More...
 
static Json FileAccessDenied (const std::string &detail, const std::string &instance="")
 Create a "File access denied" error response. More...
 
static Json RenderWindowNotAvailable (const std::string &instance="")
 Create a "Render window not available" error response. More...
 
static Json TimeNavigationNotAvailable (const std::string &instance="")
 Create a "Time navigation not available" error response. More...
 
static Json TimeStepperNotAvailable (const std::string &instance="")
 Create a "Time stepper not available" error response. More...
 
static Json EditorNotActive (const std::string &detail, const std::string &instance="")
 Create an "Editor not active" error response. More...
 
static Json RenderWindowNotFound (const std::string &windowId, const std::string &instance="")
 Create a "Render window not found" error response. More...
 
static Json UnsupportedOperation (const std::string &detail, const std::string &instance="")
 Create an "Unsupported operation" error response. More...
 
static Json RendererUnavailable (const std::string &windowId, const std::string &instance="")
 Create a "Renderer unavailable" error response. More...
 

Static Public Attributes

static constexpr const char * CODE_INVALID_REQUEST
 
static constexpr const char * CODE_NODE_NOT_FOUND
 
static constexpr const char * CODE_PROPERTY_NOT_FOUND
 
static constexpr const char * CODE_DATASTORAGE_NOT_AVAILABLE
 
static constexpr const char * CODE_INTERNAL_ERROR
 
static constexpr const char * CODE_PROPERTY_PROTECTED
 
static constexpr const char * CODE_NODE_HAS_CHILDREN
 
static constexpr const char * CODE_NO_DATA
 
static constexpr const char * CODE_NO_GEOMETRY
 
static constexpr const char * CODE_RENDERING_ERROR
 
static constexpr const char * CODE_CIRCULAR_HIERARCHY_REFERENCE
 
static constexpr const char * CODE_UNSUPPORTED_FORMAT
 
static constexpr const char * CODE_SERIALIZATION_ERROR
 
static constexpr const char * CODE_FILE_NOT_FOUND
 
static constexpr const char * CODE_FILE_READ_ERROR
 
static constexpr const char * CODE_TRANSFER_MODE_NOT_AVAILABLE
 
static constexpr const char * CODE_ACCESS_DENIED
 
static constexpr const char * CODE_UNAUTHORIZED
 
static constexpr const char * CODE_RATE_LIMIT_EXCEEDED
 
static constexpr const char * CODE_FILE_ACCESS_DENIED
 
static constexpr const char * CODE_RENDER_WINDOW_NOT_AVAILABLE
 
static constexpr const char * CODE_TIME_NAVIGATION_NOT_AVAILABLE
 
static constexpr const char * CODE_TIME_STEPPER_NOT_AVAILABLE
 
static constexpr const char * CODE_EDITOR_NOT_ACTIVE
 
static constexpr const char * CODE_RENDER_WINDOW_NOT_FOUND
 
static constexpr const char * CODE_UNSUPPORTED_OPERATION
 
static constexpr const char * CODE_RENDERER_UNAVAILABLE
 

Detailed Description

Helper class for generating RFC 9457 compliant error responses.

RFC 9457 defines a standard format for HTTP API error responses. This class provides factory methods for common error types.

Definition at line 30 of file mitkErrorResponse.h.

Member Typedef Documentation

◆ Json

Definition at line 33 of file mitkErrorResponse.h.

Member Function Documentation

◆ AccessDenied()

static Json mitk::ErrorResponse::AccessDenied ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Access denied" error response.

Used when client IP is not allowed to access the server.

Parameters
detailDescription of why access was denied
instanceRequest path
Returns
JSON error response with status 403

◆ CircularHierarchyReference()

static Json mitk::ErrorResponse::CircularHierarchyReference ( const std::string &  instance = "")
static

Create a "Circular hierarchy reference" error response.

Parameters
instanceRequest path
Returns
JSON error response with status 409

◆ Create()

static Json mitk::ErrorResponse::Create ( const std::string &  code,
const std::string &  title,
const std::string &  detail,
int  status,
const std::string &  instance = "" 
)
static

Create an RFC 9457 error response.

Parameters
codeError code (e.g., "NODE_NOT_FOUND")
titleHuman-readable title
detailDetailed error message
statusHTTP status code
instanceRequest path that caused the error
Returns
JSON object following RFC 9457 format

◆ DataStorageNotAvailable()

static Json mitk::ErrorResponse::DataStorageNotAvailable ( const std::string &  instance = "")
static

Create a "DataStorage not available" error response.

Parameters
instanceRequest path
Returns
JSON error response with status 503

◆ EditorNotActive()

static Json mitk::ErrorResponse::EditorNotActive ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Editor not active" error response.

Used when the targeted editor instance (e.g. StdMultiWidgetEditor) is not currently open in the workbench, even though the render window bridge callback is installed. Distinct from RENDER_WINDOW_NOT_AVAILABLE, which signals that no callback is registered at all (headless / plugin not loaded).

Parameters
detailOptional description (e.g. which editor is missing)
instanceRequest path
Returns
JSON error response with status 503

◆ FileAccessDenied()

static Json mitk::ErrorResponse::FileAccessDenied ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create a "File access denied" error response.

Used when a file path is outside the allowed directories.

Parameters
detailDescription of the restriction
instanceRequest path
Returns
JSON error response with status 403

◆ FileNotFound()

static Json mitk::ErrorResponse::FileNotFound ( const std::string &  filePath,
const std::string &  instance = "" 
)
static

Create a "File not found" error response.

Parameters
filePathThe file path that was not found
instanceRequest path
Returns
JSON error response with status 422

◆ FileReadError()

static Json mitk::ErrorResponse::FileReadError ( const std::string &  filePath,
const std::string &  detail,
const std::string &  instance = "" 
)
static

Create a "File read error" error response.

Parameters
filePathThe file path that could not be read
detailDescription of the read error
instanceRequest path
Returns
JSON error response with status 422

◆ InternalError()

static Json mitk::ErrorResponse::InternalError ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Internal error" response.

Parameters
detailDescription of the error
instanceRequest path
Returns
JSON error response with status 500

◆ InvalidRequest()

static Json mitk::ErrorResponse::InvalidRequest ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Invalid request" error response.

Parameters
detailDescription of what was invalid
instanceRequest path
Returns
JSON error response with status 400

◆ NoData()

static Json mitk::ErrorResponse::NoData ( const std::string &  nodeUid,
const std::string &  instance = "" 
)
static

Create a "No data" error response.

Parameters
nodeUidThe node UID that has no data
instanceRequest path
Returns
JSON error response with status 404

◆ NodeHasChildren()

static Json mitk::ErrorResponse::NodeHasChildren ( int  childrenCount,
const std::string &  instance = "" 
)
static

Create a "Node has children" error response.

Parameters
childrenCountThe number of children
instanceRequest path
Returns
JSON error response with status 409

◆ NodeNotFound()

static Json mitk::ErrorResponse::NodeNotFound ( const std::string &  uid,
const std::string &  instance = "" 
)
static

Create a "Node not found" error response.

Parameters
uidThe UID that was not found
instanceRequest path
Returns
JSON error response with status 404

◆ NoGeometry()

static Json mitk::ErrorResponse::NoGeometry ( const std::string &  nodeUid,
const std::string &  instance = "" 
)
static

Create a "No geometry" error response.

Parameters
nodeUidThe node UID whose data has no usable time geometry
instanceRequest path
Returns
JSON error response with status 422

◆ PropertyNotFound()

static Json mitk::ErrorResponse::PropertyNotFound ( const std::string &  propertyKey,
const std::string &  nodeUid,
const std::string &  instance = "" 
)
static

Create a "Property not found" error response.

Parameters
propertyKeyThe property key that was not found
nodeUidThe node UID
instanceRequest path
Returns
JSON error response with status 404

◆ PropertyProtected()

static Json mitk::ErrorResponse::PropertyProtected ( const std::string &  propertyKey,
const std::string &  instance = "" 
)
static

Create a "Property protected" error response.

Parameters
propertyKeyThe protected property key
instanceRequest path
Returns
JSON error response with status 400

◆ RateLimitExceeded()

static Json mitk::ErrorResponse::RateLimitExceeded ( int  retryAfterSeconds,
const std::string &  instance = "" 
)
static

Create a "Rate limit exceeded" error response.

Parameters
retryAfterSecondsSeconds until the client can retry
instanceRequest path
Returns
JSON error response with status 429

◆ RendererUnavailable()

static Json mitk::ErrorResponse::RendererUnavailable ( const std::string &  windowId,
const std::string &  instance = "" 
)
static

Create a "Renderer unavailable" error response.

Used when a window exists but its renderer is currently null, indicating a server-side state inconsistency rather than a missing window.

Parameters
windowIdThe window id whose renderer is unavailable
instanceRequest path
Returns
JSON error response with status 500

◆ RenderingError()

static Json mitk::ErrorResponse::RenderingError ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create a "Rendering error" error response.

Parameters
detailDescription of the rendering failure
instanceRequest path
Returns
JSON error response with status 422

◆ RenderWindowNotAvailable()

static Json mitk::ErrorResponse::RenderWindowNotAvailable ( const std::string &  instance = "")
static

Create a "Render window not available" error response.

Used when the screenshot provider is not connected (headless mode or Qt plugin not loaded).

Parameters
instanceRequest path
Returns
JSON error response with status 503

◆ RenderWindowNotFound()

static Json mitk::ErrorResponse::RenderWindowNotFound ( const std::string &  windowId,
const std::string &  instance = "" 
)
static

Create a "Render window not found" error response.

Used when a per-window URL segment does not name a known render window of the targeted editor.

Parameters
windowIdThe window id from the URL
instanceRequest path
Returns
JSON error response with status 404

◆ SerializationError()

static Json mitk::ErrorResponse::SerializationError ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create a "Serialization error" error response.

Parameters
detailDescription of the serialization failure
instanceRequest path
Returns
JSON error response with status 500

◆ TimeNavigationNotAvailable()

static Json mitk::ErrorResponse::TimeNavigationNotAvailable ( const std::string &  instance = "")
static

Create a "Time navigation not available" error response.

Used when the TimeNavigationController is null (e.g. no rendering manager active).

Parameters
instanceRequest path
Returns
JSON error response with status 503

◆ TimeStepperNotAvailable()

static Json mitk::ErrorResponse::TimeStepperNotAvailable ( const std::string &  instance = "")
static

Create a "Time stepper not available" error response.

Used when the TimeNavigationController's stepper is null.

Parameters
instanceRequest path
Returns
JSON error response with status 500

◆ TransferModeNotAvailable()

static Json mitk::ErrorResponse::TransferModeNotAvailable ( const std::string &  requestedMode,
const std::vector< std::string > &  availableModes,
const std::string &  instance = "" 
)
static

Create a "Transfer mode not available" error response.

Parameters
requestedModeThe requested transfer mode that is not supported
availableModesList of available transfer modes
instanceRequest path
Returns
JSON error response with status 406

◆ Unauthorized()

static Json mitk::ErrorResponse::Unauthorized ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Unauthorized" error response.

Used when authentication is required but not provided or invalid.

Parameters
detailDescription of the authentication failure
instanceRequest path
Returns
JSON error response with status 401

◆ UnsupportedFormat()

static Json mitk::ErrorResponse::UnsupportedFormat ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Unsupported format" error response.

Parameters
detailDescription of the format issue
instanceRequest path
Returns
JSON error response with status 415

◆ UnsupportedOperation()

static Json mitk::ErrorResponse::UnsupportedOperation ( const std::string &  detail,
const std::string &  instance = "" 
)
static

Create an "Unsupported operation" error response.

Used when a sub-resource does not apply to the addressed window (e.g. selected-slice on the 3d window).

Parameters
detailDescription of the unsupported operation
instanceRequest path
Returns
JSON error response with status 404

Member Data Documentation

◆ CODE_ACCESS_DENIED

constexpr const char* mitk::ErrorResponse::CODE_ACCESS_DENIED
staticconstexpr

Definition at line 52 of file mitkErrorResponse.h.

◆ CODE_CIRCULAR_HIERARCHY_REFERENCE

constexpr const char* mitk::ErrorResponse::CODE_CIRCULAR_HIERARCHY_REFERENCE
staticconstexpr

Definition at line 46 of file mitkErrorResponse.h.

◆ CODE_DATASTORAGE_NOT_AVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_DATASTORAGE_NOT_AVAILABLE
staticconstexpr

Definition at line 39 of file mitkErrorResponse.h.

◆ CODE_EDITOR_NOT_ACTIVE

constexpr const char* mitk::ErrorResponse::CODE_EDITOR_NOT_ACTIVE
staticconstexpr

Definition at line 59 of file mitkErrorResponse.h.

◆ CODE_FILE_ACCESS_DENIED

constexpr const char* mitk::ErrorResponse::CODE_FILE_ACCESS_DENIED
staticconstexpr

Definition at line 55 of file mitkErrorResponse.h.

◆ CODE_FILE_NOT_FOUND

constexpr const char* mitk::ErrorResponse::CODE_FILE_NOT_FOUND
staticconstexpr

Definition at line 49 of file mitkErrorResponse.h.

◆ CODE_FILE_READ_ERROR

constexpr const char* mitk::ErrorResponse::CODE_FILE_READ_ERROR
staticconstexpr

Definition at line 50 of file mitkErrorResponse.h.

◆ CODE_INTERNAL_ERROR

constexpr const char* mitk::ErrorResponse::CODE_INTERNAL_ERROR
staticconstexpr

Definition at line 40 of file mitkErrorResponse.h.

◆ CODE_INVALID_REQUEST

constexpr const char* mitk::ErrorResponse::CODE_INVALID_REQUEST
staticconstexpr

Definition at line 36 of file mitkErrorResponse.h.

◆ CODE_NO_DATA

constexpr const char* mitk::ErrorResponse::CODE_NO_DATA
staticconstexpr

Definition at line 43 of file mitkErrorResponse.h.

◆ CODE_NO_GEOMETRY

constexpr const char* mitk::ErrorResponse::CODE_NO_GEOMETRY
staticconstexpr

Definition at line 44 of file mitkErrorResponse.h.

◆ CODE_NODE_HAS_CHILDREN

constexpr const char* mitk::ErrorResponse::CODE_NODE_HAS_CHILDREN
staticconstexpr

Definition at line 42 of file mitkErrorResponse.h.

◆ CODE_NODE_NOT_FOUND

constexpr const char* mitk::ErrorResponse::CODE_NODE_NOT_FOUND
staticconstexpr

Definition at line 37 of file mitkErrorResponse.h.

◆ CODE_PROPERTY_NOT_FOUND

constexpr const char* mitk::ErrorResponse::CODE_PROPERTY_NOT_FOUND
staticconstexpr

Definition at line 38 of file mitkErrorResponse.h.

◆ CODE_PROPERTY_PROTECTED

constexpr const char* mitk::ErrorResponse::CODE_PROPERTY_PROTECTED
staticconstexpr

Definition at line 41 of file mitkErrorResponse.h.

◆ CODE_RATE_LIMIT_EXCEEDED

constexpr const char* mitk::ErrorResponse::CODE_RATE_LIMIT_EXCEEDED
staticconstexpr

Definition at line 54 of file mitkErrorResponse.h.

◆ CODE_RENDER_WINDOW_NOT_AVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_RENDER_WINDOW_NOT_AVAILABLE
staticconstexpr

Definition at line 56 of file mitkErrorResponse.h.

◆ CODE_RENDER_WINDOW_NOT_FOUND

constexpr const char* mitk::ErrorResponse::CODE_RENDER_WINDOW_NOT_FOUND
staticconstexpr

Definition at line 60 of file mitkErrorResponse.h.

◆ CODE_RENDERER_UNAVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_RENDERER_UNAVAILABLE
staticconstexpr

Definition at line 62 of file mitkErrorResponse.h.

◆ CODE_RENDERING_ERROR

constexpr const char* mitk::ErrorResponse::CODE_RENDERING_ERROR
staticconstexpr

Definition at line 45 of file mitkErrorResponse.h.

◆ CODE_SERIALIZATION_ERROR

constexpr const char* mitk::ErrorResponse::CODE_SERIALIZATION_ERROR
staticconstexpr

Definition at line 48 of file mitkErrorResponse.h.

◆ CODE_TIME_NAVIGATION_NOT_AVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_TIME_NAVIGATION_NOT_AVAILABLE
staticconstexpr

Definition at line 57 of file mitkErrorResponse.h.

◆ CODE_TIME_STEPPER_NOT_AVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_TIME_STEPPER_NOT_AVAILABLE
staticconstexpr

Definition at line 58 of file mitkErrorResponse.h.

◆ CODE_TRANSFER_MODE_NOT_AVAILABLE

constexpr const char* mitk::ErrorResponse::CODE_TRANSFER_MODE_NOT_AVAILABLE
staticconstexpr

Definition at line 51 of file mitkErrorResponse.h.

◆ CODE_UNAUTHORIZED

constexpr const char* mitk::ErrorResponse::CODE_UNAUTHORIZED
staticconstexpr

Definition at line 53 of file mitkErrorResponse.h.

◆ CODE_UNSUPPORTED_FORMAT

constexpr const char* mitk::ErrorResponse::CODE_UNSUPPORTED_FORMAT
staticconstexpr

Definition at line 47 of file mitkErrorResponse.h.

◆ CODE_UNSUPPORTED_OPERATION

constexpr const char* mitk::ErrorResponse::CODE_UNSUPPORTED_OPERATION
staticconstexpr

Definition at line 61 of file mitkErrorResponse.h.


The documentation for this class was generated from the following file: