본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    라이브러리 · std.typeset

    TypesetError.InvalidInput

    Invalid measured data or boundary structure.

    TypesetError.InvalidInput(string)
    수신자
    해당 없음
    최소 인자 수
    1
    최대 인자 수
    1

    Declaration and parameters

    링크

    사용 조건

    기본 포함 · 미정

    Import std.typeset in language mode 5.21.

    The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.

    수신자

    매개변수 제약

    TypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.

    The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.

    NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.

    NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.

    A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.

    breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.

    The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.

    classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.

    An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.

    결과

    효과

    실패

    Result and effects

    링크

    Carries explanatory text. Match the variant to distinguish malformed input from a missing plan.

    Why

    링크

    A named failure category lets callers select a recovery without depending on message wording.

    Resolved contracts

    링크

    Related entries

    링크

    std.typeset →

    Distinguish invalid data from unavailable plans

    링크
    규칙topaz.stdlib.contract.typeset-errors.rule

    Distinguish invalid data from unavailable plans

    TypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.

    The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.

    NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.

    NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.

    A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.

    breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.

    The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.

    classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.

    An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.

    이유

    Applications can repair malformed data, choose another policy, or report the absence of a plan when these outcomes stay distinct. Named variants provide that decision without relying on diagnostic wording or silently substituting a different algorithm.

    Preserve explanatory error payloads

    링크
    main.tpzPreserve explanatory error payloads플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. let failures: Array<ts.TypesetError> = [
    4. ts.TypesetError.InvalidInput("measured unit"),
    5. ts.TypesetError.InvalidPolicy("line target")
    6. ]
    7. for failure in (failures) {
    8. match (failure) {
    9. case InvalidInput(message) => io.writeLine("input {message}")
    10. case InvalidPolicy(message) => io.writeLine("policy {message}")
    11. case _ => io.writeLine("unexpected variant")
    12. }
    13. }
    기대 출력종료 코드 0
    input measured unit
    policy line target
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. input measured unit
    2. policy line target

    Report an invalid paragraph policy before an invalid unit index

    링크
    main.tpzReport an invalid paragraph policy before an invalid unit index플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. let items: Array<ts.Item> = [
    4. ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),
    5. ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })
    6. ]
    7. let input = ts.Paragraph {
    8. grid: ts.DistanceGrid.MilliPoint(),
    9. items: items,
    10. geometry: ts.LineGeometry { bodyTarget: 0pt, firstTarget: 0pt, dropCapSpan: 0, dropCapInset: 0pt },
    11. justification: ts.JustificationPolicy {
    12. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    13. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    14. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    15. latinSpacing: None(), cjkStretchRatio: 0.0
    16. },
    17. costModel: ts.CostModel.FixedPoint(),
    18. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    19. }
    20. match (ts.breakParagraph(input)) {
    21. case Err(InvalidPolicy(_)) => io.writeLine("InvalidPolicy")
    22. case _ => io.writeLine("unexpected result")
    23. }
    기대 출력종료 코드 0
    InvalidPolicy
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. InvalidPolicy

    메뉴

    다운로드 →