Skip to content

Commit

Permalink
Medias: rule out error case
Browse files Browse the repository at this point in the history
  • Loading branch information
panglesd committed Aug 19, 2024
1 parent 2666cf3 commit 34ef32c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/document/comment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,10 @@ let rec nestable_block_element :
match href with
| `Reference (`Resolved r) -> (
let id =
Odoc_model.Paths.Reference.Resolved.(identifier (r :> t))
Odoc_model.Paths.Reference.Resolved.Asset.(identifier (r :> t))
in
match Url.from_identifier ~stop_before:false id with
| Ok url -> Target.Internal (Resolved url)
| Error exn ->
(* FIXME: better error message *)
Printf.eprintf "Id.href failed: %S\n%!"
(Url.Error.to_string exn);
Internal Unresolved)
match Url.from_asset_identifier id with
| url -> Target.Internal (Resolved url))
| `Reference _ -> Internal Unresolved
| `Link href -> External href
in
Expand Down
2 changes: 2 additions & 0 deletions src/document/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ let from_identifier ~stop_before = function
Ok (from_path @@ Path.from_identifier p)
| p -> Anchor.from_identifier p

let from_asset_identifier p = from_path @@ Path.from_identifier p

let kind id =
match Anchor.from_identifier id with
| Error e -> failwith (Error.to_string e)
Expand Down
2 changes: 2 additions & 0 deletions src/document/url.mli
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ val from_path : Path.t -> t

val from_identifier : stop_before:bool -> Identifier.t -> (t, Error.t) result

val from_asset_identifier : Identifier.AssetFile.t -> t

val kind : Identifier.t -> kind

val render_path : Odoc_model.Paths.Path.t -> string
2 changes: 2 additions & 0 deletions src/model/paths.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ module Reference = struct
end

module Asset = struct
let identifier = function `Identifier id -> id

type t = Paths_types.Resolved_reference.asset
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/model/paths.mli
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ module rec Reference : sig

module Asset : sig
type t = Paths_types.Resolved_reference.asset

val identifier : t -> Identifier.AssetFile.t
end

type t = Paths_types.Resolved_reference.any
Expand Down

0 comments on commit 34ef32c

Please sign in to comment.