Похожие чаты

Guys let's say I have an error and I want

to wrap it using something like fmt.Errorf but I don't want the previous error to show on the string when doing .Error() method. What can I do?

15 ответов

34 просмотра

you want to wrap but you don't want to wrap? :D

DAZ- Автор вопроса
Roman Sharkov
you want to wrap but you don't want to wrap? :D

I want to wrap the error without concatenating the output strings

Create your own error struct and implement the Error interface on it

DAZ- Автор вопроса
woto 「 噂 」
Create your own error struct and implement the Err...

I did, I was looking for something on the stdlib that I might had missed

DAZ
I did, I was looking for something on the stdlib t...

hiding errors when wrapping would be all sorts of wrong. Why would you hide it?

DAZ- Автор вопроса
Roman Sharkov
hiding errors when wrapping would be all sorts of ...

an external function returns un ugly message that I don't want to display to the end user, I want to wrap it into an error wich still say where it went wrong but preserving the type of the original error by wrapping it

DAZ- Автор вопроса
Roman Sharkov
use a custom error type :)

Is what I did, as I said I just wanted to see if there was something else type errorWrapper struct { wrapped error message string } func wrapError(out string, err error) error { return errorWrapper{err, out} } func (e errorWrapper) Error() string { return e.message } func (e errorWrapper) Unwrap() error { return e.wrapped }

DAZ- Автор вопроса
Roman Sharkov
unexported tho?

I use it only internally 🤔

DAZ
I use it only internally 🤔

I had a team mate in apex legends a few minutes ago with your name, toxic AF. Unrelated but amusing none the less 😂

DAZ- Автор вопроса

You can create your own error container

Похожие вопросы

Обсуждают сегодня

И ещё вопрос: можно ли типа как на дос как-то запариться и с помощью прерываний выводить текст, вместо функции printf ?
НѣкъиⰘижєжєиꙁъвьсєсвѣтьноѣсѣтиѥсть•
34
'frakturBold' => ['𝖆', '𝖇', '𝖈', '𝖉', '𝖊', '𝖋', '𝖌', '𝖍', '𝖎', '𝖏', '𝖐', '𝖑', '𝖒', '𝖓', '𝖔', '𝖕', '𝖖', '𝖗', '𝖘', '𝖙', '𝖚', '𝖛', '𝖜', '𝖝', '𝖞', '𝖟', '𝕬', '𝕭', '𝕮', '𝕯'...
Roma
4
Ладно, ещё тупого спрошу. Код должен банально вывести значение регистра на консоль, на деле же не выводя ничего, просто оставляя нерабочую консоль (открыта, ничего не написан...
НѣкъиⰘижєжєиꙁъвьсєсвѣтьноѣсѣтиѥсть•
25
здравствуйте. пытаюсь проверить, содержится ли в десятичном представлении инта некоторая цифра. совершаю: strstr(x, "5") != NULL) получаю ошибку с фото (заведомо неработающий ...
Катя Шевчук🪇
17
Let me insert my "5++" kilocents into how zcash should be positioned (and how it would have been positioned/adopted from day one). You are allowed to believe or not believe in...
eBiker
5
Что там вообще с кроссплатформенностью?
🄼🄰🄺🅉🄰🄸
23
How did we have so many dormant scammers in here? Who are these people. It’s been years. We know each other. If you dm me “I’ve been an og” but haven’t said a single word her...
Justin | LGCY |
49
{ char buff = *start; *start = *end; *end = buff; } Из-за этой строчки? Что каждый символ через перем бафф? Как вариант использовать другие со...
Wenks
12
Hello Everyone 🙌🏻💜 Happy (?) Friday to everyone 😁😁 I have read through all the comments/feedback/complaints in the last 2 days following the CEO Update AMA. Clearly the ...
Patrick - Ultra.io
5
In a country where censorship and arbitrary decisions are the order of the day, offering a message of hope to workers and youth is necessary, but it is only possible with expe...
Ibrahim Rabiu
1
Карта сайта