MulterError class doesn't allow custom messages.
See original GitHub issueI didn’t expect this behavior. I expected it to create a custom message that I provided.
File type not supported!
I am checking meme types using the filter. I thought I could use the MulterError
class to nicely catch and organize its errors.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Error handling when uploading file using multer with expressjs
You can use onFileUploadComplete to log a message when the upload is done, and compare that to when your route handler is called....
Read more >Fix "Unexpected field" Error From Multer - Maxim Orlov
Learn how to decypher & fix this cryptic error message from multer, and finally implement working file uploads in Node.js.
Read more >Multer: Easily upload files with Node.js and Express
In this article, we'll learn the purpose of Multer in handling files in submitted forms. We'll also explore Multer by building a mini...
Read more >Handling File Uploads in Node.js with Express and Multer
Project Setup. Since we won't be storing our images in a database, but rather a simple folder for brevity and simplicity, let's make...
Read more >Using Multer for File Uploads in Node.js | by Uriel Rodriguez
The first thing to note is the imports that allow separating the User routes into its ... return cb(new Error('some custom error message');...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So in the multer config
We can do this:
For limits, any limits check that fails will throw a multer error. For fileFilter, inorder for it to fail, we either add an error to the callback function or return false. I see false good for multiple files uploads that we do not want to stop all the uploads. So where does this error end up going when using express? Well to the last middleware express designates for error handling.
When we try and use the Multer error handler, it doesn’t use the provided error because
I handle my server errors in this fashion and for my own custom errors I create, I would add a status property and other properties so that i can do something like this:
@anuraghazra solution work form mi,
#ImageFilter function
#Express handlerError
Sorry for my english