Last active
September 26, 2019 00:48
-
-
Save AnuchitO/e755c956fddca7d21ca8c326be85e8c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| errOriginal := &os.PathError{Op: "read", Path: "/a/b", Err: errors.New("read error")} | |
| // ไม่ได้ห่อ แค่สร้าง error ใหม่จาก error เดิม | |
| err := fmt.Errorf("create new error: %v", errOriginal) | |
| fmt.Printf("error value: %T\n", err) | |
| // สร้าง error ใหม่ ยังเก็บ(ห่อ) type เดิมไว้ข้างใน | |
| err = fmt.Errorf("wrapped error: %w", errOriginal) | |
| fmt.Printf("error value: %T\n", err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment