problemTypeUri function

String problemTypeUri({
  1. required ErrorPortal portal,
  2. required ProblemTypeSegment version,
  3. required ProblemTypeSegment id,
})

Builds the RFC 9457 type URI from an ErrorPortal config block.

This is the single source of the type-URI template (C0 §2). Every problem — catalog entries, runtime envelopes, local errors — resolves its type through this function.

id is the WIRE id and must be snake_case per R-E14 (problemWireIdPattern); version must be v<n>.

final uri = problemTypeUri(
  portal: portal,
  version: 'v1',
  id: 'entity_not_found',
);
// https://docs.raichu.cluster.atomi.cloud/docs/raichu/dotnet/user/v1/entity_not_found

Implementation

String problemTypeUri({
  required ErrorPortal portal,
  required ProblemTypeSegment version,
  required ProblemTypeSegment id,
}) {
  _check('scheme', portal.scheme);
  _checkHost(portal.scheme, portal.host);
  _check('landscape', portal.landscape);
  _check('platform', portal.platform);
  _check('service', portal.service);
  _check('module', portal.module);
  _check('version', version, problemVersionPattern);
  _check('id', id, problemWireIdPattern);
  return '${portal.scheme}://${portal.host}/docs/${portal.landscape}'
      '/${portal.platform}/${portal.service}/${portal.module}/$version/$id';
}