Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override error formatting #2717

Merged

Conversation

firelizzard18
Copy link
Contributor

@firelizzard18 firelizzard18 commented Jun 9, 2023

Description

When a call from the frontend to the backend returns an error, this change allows the formatting of the error to be customized. This allows for preserving the structure of the error in cases where the error is providing information the frontend needs to act on.

Fixes #2569

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update maybe?

How Has This Been Tested?

I've been running this for a while with my own app. Testing is pretty straightforward - I override the error formatter with one that formats the error as a JSON object then use that object on the frontend.

  • Windows
  • macOS
  • Linux

Test Configuration

I don't know why this says my system is missing dependencies. Wails definitely works.

# System

OS           | Gentoo  
Version      | 2.13    
ID           | gentoo  
Go Version   | go1.19.2
Platform     | linux   
Architecture | amd64   

# Wails

Version         | v2.4.1                                  
Revision        | bd96e617d8f73a11b7a086ff64657043b72a969b
Modified        | false                                   
Package Manager | emerge                                  

# Dependencies

Dependency | Package Name | Status    | Version
*docker    | Unknown      | Not Found | 23.0.3 
gcc        | Unknown      | Not Found | 12.2.1 
libgtk-3   | Unknown      | Not Found |        
libwebkit  | Unknown      | Not Found |        
npm        | Unknown      | Not Found | 8.19.4 
pkg-config | Unknown      | Not Found | 1.8.1  
* - Optional Dependency

# Diagnosis

Your system has missing dependencies!
Fatal:
Required dependencies missing: gcc libgtk-3 libwebkit npm pkg-config
Please read this article on how to resolve this: https://wails.io/guides/resolving-missing-packages
 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@leaanthony
Copy link
Member

Thanks for taking the time to open this @firelizzard18 👍 Looks good overall. Could you please update the options docs with the new option and a description of what it's for? Thanks!

@firelizzard18
Copy link
Contributor Author

@leaanthony Does this look good? 0fb2cb5

@leaanthony
Copy link
Member

@firelizzard18 - Sorry this slipped through the net! If you fix the conflict we can get this moving 👍

@firelizzard18
Copy link
Contributor Author

@leaanthony I rebased and force pushed

@leaanthony leaanthony self-requested a review July 13, 2023 10:37
@leaanthony leaanthony merged commit 22cfcbd into wailsapp:master Jul 13, 2023
9 checks passed
@firelizzard18 firelizzard18 deleted the override-error-marshalling branch July 13, 2023 16:46
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.

Allow the app to override how errors are marshalled
2 participants