// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT import dagger/types.{type Client, type Try} as types import dagger/interpreter import dagger/dsl/types as t import gleam/dynamic/decode import gleam/list pub fn error(message message: String) -> t.Error { let field = types.Field(name: "error", args: [#("message", types.GString(message))], subfields: []) t.Error(op: types.Pure([field])) } /// A unique identifier for this Error. pub fn id(parent: t.Error) -> t.Error { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Error(op: new_op) } /// A description of the error. pub fn message(parent: t.Error, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "message", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.string)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("message"))) } } ) } handler(interpreter.run(op, client)) } /// The extensions of the error. pub fn values(parent: t.Error, select select: fn(t.ErrorValue) -> List(types.Field), client client: Client, then handler: fn(Try(List(t.ErrorValue))) -> a) -> a { let subfields = select(t.ErrorValue(op: types.Pure([]))) let field = types.Field(name: "values", args: [], subfields: subfields) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.list(decode.dynamic))) { Ok(items) -> types.Pure(Ok(list.map(items, fn(_) { t.ErrorValue(op: types.Pure(full_query)) }))) Error(_) -> types.Pure(Error(types.DecodingError("values"))) } } ) } handler(interpreter.run(op, client)) } /// Add a value to the error. pub fn with_value(parent: t.Error, name name: String, value value: String) -> t.Error { let field = types.Field(name: "withValue", args: [#("name", types.GString(name)), #("value", types.GString(value))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Error(op: new_op) }