Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 Copy type on transparent wrapping and hide type modifier transparent by funny-falcon-at-joomcode · Pull Request #13 · joomcode/errorx · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

funny-falcon-at-joomcode
Copy link
@funny-falcon-at-joomcode funny-falcon-at-joomcode commented Dec 7, 2018

Currently, transparent types are completely inaccessible, and they don't affect any thing.
Therefore there is no need to keep transparent type in an error, and no need to traverse transparent cause chain to reach the type, because it is simpler just to copy type.

Probably this PR is not complete:

  • should Builder.Transparent() be removed or not? Or should typeModifierTransparent be removed?
  • should tests for transparent namespaces be removed?

Note: I believe transparent type could be used for injecting new Traits into error (after modification in Error.HasTrait function), and then this PR is not valid.

Copy link
Collaborator
@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given it a thought, and this looks good to me.
The concept of transparent wrap evolved along with errorx, and at this point it is indeed something best left mostly hidden. It is most probably a bad idea to add traits via transparent wrap. Such error type names are not present in error message and may not be checked against.
With this in mind, the idea to make this modifier private seems OK.
It is also OK to copy the type, as there is no way to observe the wrapped type anyway.

One thing that still can be done via this kind of wrap is adding property. I can see no reason to remove this, and this PR leaves it intact.
It is best to leave the tests: transparency modifier is private now, but it still uses the mechanism.

As for ErrorBuilder.Transparent(), I have no strong arguments for its preservation or removal. It is not broken in any way, so we may just as well leave it there.

@g7r
Copy link
Contributor
g7r commented Dec 13, 2018

Hiding errorx.TypeModifierTransparent forbids the following use case:

// transparent wrapper without stacktrace
var errWrapper = errorx.CommonErrors.NewType("wrapper").
	ApplyModifiers(errorx.TypeModifierTransparent, errorx.TypeModifierOmitStackTrace)

...
// like `errorx.Decorate` but guarantees that no stack trace will be added
return errWrapper.Wrap(io.EOF, "additional message")

There are four ways to enable it:

  1. Leave errorx.TypeModifierTransparent public thus keeping status quo
  2. Add errorx.TransparentWrapperWithoutStacktrace error type
  3. Add errorx.DecorateWithNoStackTrace helper func
  4. Declare this use case as marginal and leave users to resort to errorx.ErrorBuilder

// TypeModifierTransparent is a type modifier; an error type with such modifier creates transparent wrappers by default
TypeModifierTransparent TypeModifier = 1
// typeModifierTransparent is a type modifier; an error type with such modifier creates transparent wrappers by default
typeModifierTransparent TypeModifier = 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kinda weird to have public and private type modifiers together in one public place. Maybe move typeModifierTransparent elsewhere?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about removing TypeModifierTransparent at all, and using Builder.Transparent() method instead.
What do you think?
Or do not change its access mode at all to preserve api compatibility (see @g7r comment)

@PeterIvanov
Copy link
Collaborator

@g7r I can see no benefit from transparency in this particular example.
If you want to have a wrapper with no stack trace around io.EOF, wrap with a private type suits your needs. There is no way to check against io.EOF wrapped in errorx error anyway, other than manually unroll the Cause chain, and you can do so even through opaque wrap.

I could conjure up another example that would be trickier in this regard, but if we struggle to find one, then I'd stick to option 4 just now.

@g7r
Copy link
Contributor
g7r commented Dec 13, 2018

@g7r I can see no benefit from transparency in this particular example.
If you want to have a wrapper with no stack trace around io.EOF, wrap with a private type suits your needs. There is no way to check against io.EOF wrapped in errorx error anyway, other than manually unroll the Cause chain, and you can do so even through opaque wrap.

I could conjure up another example that would be trickier in this regard, but if we struggle to find one, then I'd stick to option 4 just now.

errWrapper wraps external-type errors without stacktrace and transparently wraps errorx-type errors. However it would be more honest if both types of errors will be wrapped opaquely. Therefore I should drop TypeModifierTransparent from error type above. OK.

@PeterIvanov
Copy link
Collaborator

We seem to have abandoned this PR.
I suggest either to close it or to think it over again and come up with some sort of revised summary, to use it as a new starting point for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

0