ExScim.Error (ex_scim v0.2.2)

Copy Markdown View Source

SCIM error handling and standardization per RFC 7644 Section 3.12.

This module provides SCIM error types, standardization functions, and error response formatting that maintains proper separation between core SCIM logic and web concerns.

Summary

Types

Standard SCIM error response structure.

SCIM error types as defined in RFC 7644 Section 3.12.

Individual validation error for multi-error responses.

Functions

Creates a standardized error response from an HTTP status code.

Creates a standard SCIM error response structure.

Creates a SCIM validation error response with multiple errors.

Maps HTTP status codes to appropriate SCIM error types and default messages.

Converts SCIM error types to their string representation.

Types

error_response()

@type error_response() :: %{
  required(String.t()) => [String.t()],
  required(String.t()) => String.t(),
  required(String.t()) => String.t(),
  optional(String.t()) => String.t(),
  optional(String.t()) => [validation_error()]
}

Standard SCIM error response structure.

Contains string keys: "schemas", "status", "scimType", "detail", "errors". Generic String.t() keys used due to Elixir type system limitations.

scim_type()

@type scim_type() ::
  :invalid_filter
  | :invalid_path
  | :invalid_syntax
  | :invalid_target
  | :invalid_value
  | :invalid_version
  | :mutability
  | :no_authn
  | :no_target
  | :not_found
  | :sensitive
  | :too_large
  | :too_many
  | :uniqueness
  | :forbidden
  | :insufficient_rights
  | :insufficient_scope
  | :invalid_credentials
  | :internal_error
  | :unknown

SCIM error types as defined in RFC 7644 Section 3.12.

validation_error()

@type validation_error() :: %{
  required(String.t()) => String.t(),
  required(String.t()) => String.t()
}

Individual validation error for multi-error responses.

Contains string keys: "path", "message".

Functions

build_error_from_status(status_code)

@spec build_error_from_status(integer()) :: error_response()

Creates a standardized error response from an HTTP status code.

build_error_response(status_code, scim_type, detail)

@spec build_error_response(integer(), scim_type(), String.t()) :: error_response()

Creates a standard SCIM error response structure.

build_validation_error_response(errors)

@spec build_validation_error_response([validation_error()]) :: error_response()

Creates a SCIM validation error response with multiple errors.

map_status_to_scim_error(arg1)

@spec map_status_to_scim_error(integer()) :: {scim_type(), String.t()}

Maps HTTP status codes to appropriate SCIM error types and default messages.

scim_type_to_string(atom)

@spec scim_type_to_string(scim_type()) :: String.t()

Converts SCIM error types to their string representation.