Category Archives: Error

Unknown custom element: [xxx] – did you register the component correctly…

Solution

1. See if the component is registered on the page

     export default {
        data(){
              return{
        },
        components: {
            FullCalendar// //Register Component
        },
      }
    }

2. Check to see if a correctly written component is introduced into the page

<script>
    import FullCalendar from '@fullcalendar/vue'
</script>

3. This error can be reported by checking whether the above two points are correct, which can solve the error reporting problem of custom components.

Axios request failed, get the status code and error information, how to encapsulate the function dealing with the public error code

If the Axios request fails, how to get the status code and error information returned by the interface? How to encapsulate the function to handle the common error code?

The method is as follows

1. Use the object to map the status code to the corresponding prompt

const codeMessage = {
    200: 'The server successfully returned the requested data.' ,
    201: 'New or modified data was successful.' ,
    202: 'A request has been queued in the background (asynchronous task).' ,
    204: 'Deleting data was successful.' ,
    400: 'There was an error in the outgoing request, the server did not perform a new or modified data operation.' ,
    401: 'The user does not have permission (wrong token, username, password).' ,
    403: 'The user is authorized, but access is forbidden.' ,
    404: 'The request was sent for a record that does not exist and the server did not perform the operation.' ,
    406: 'The format of the request was not available.' ,
    410: 'The requested resource was permanently deleted and will not be available again.' ,
    422: 'A validation error occurred when an object was created.' ,
    500: 'An error occurred on the server, please check the server.' ,
    502: 'Gateway error.' ,
    503: 'Service is not available, the server is temporarily overloaded or under maintenance.' ,
    504: 'Gateway timeout.',
};

2. Encapsulate the common error request function

function errorHandle(error) {
    if (error.response) {
        // The request was made and the server responded with a status code 
        // The request has been sent and the server responds with a status code
        // that falls out of the range of 2xx out of the range of 2xx
        const { status } = error.response;
        if(status){
            const errorText = codeMessage[status]
            // notification is an Ant Design Anthem component and needs to be replaced with a self-defined component
            notification.error({
                message: `Error code ${status}`,
                description: `${
                    errorText
                }`,
                duration: 2.5
            });
        }
    } else {
        notification.error({
            message: 'request error!',
            description: '',
            duration: 2.5
        });
    }
}

3. Use error request function in common request response interceptor (recommended)

axios.interceptors.response.use(
function(){
	// Interface access success public interceptor
},
function(error){
	// Interface access failure public interceptor
	errorHandle(error)
})

4. Using the wrong request function in a request (not recommended)

axios.get('api/xxxx').then(res => {
	console.log(res); // The request succeeds in returning data
}).catch(errorHandle); // errorHandle is a wrapped public callback

5. The error parameter in Axios catch contains
error.response
error.response.headers
error.response.status //Status code error.response.data
error.request
error.message
error.config
Wait a minute…

Ajax prevents page requests from reporting errors

When sending an Ajax request, if there is no corresponding file content in the requested file, or if the path is wrong, the page will report an error. Here’s a brief introduction, such as how to avoid page error reporting, or page compatibility

xhr.onreadystatechange = function() {
  
  if(xhr.readyState == 4) {
    //Verify that the file is available, using status to determine the status
    if(xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
      box.innerHTML = xhr.responseText;
    }else {
      // Error page, server error or not found error
      console.error("Error Request")
    }
  }
}

This page will not appear the following error problem

The error will be output on the console

JSON parse error: raw timestamp (1595952000000) not allowed for

The solution is to add a local DataTime serialized configuration class, which will be transferred again when accepted

@Configuration
public class LocalDateTimeSerializerConfig {

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
        return builder -> {
            builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer());
            builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer());
        };
    }

    /**
     * Serialization
     */
    public static class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
        @Override
        public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
                throws IOException {
            if (value != null) {
                long timestamp = value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
                gen.writeNumber(timestamp);
            }
        }
    }

    /**
     *Deserialization
     */
    public static class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
        @Override
        public LocalDateTime deserialize(JsonParser p, DeserializationContext deserializationContext)
                throws IOException {
            long timestamp = p.getValueAsLong();
            if (timestamp > 0) {
                return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
            } else {
                return null;
            }
        }
    }
}

TypeError: unsupported format string passed to numpy.ndarray.__format__

a_ = np.array([12]).reshape(-1, 1)
a = model.predict(a_)
print("Predicting a 12-inch pizza.{:.2f}".format(a))

Error:
typeerror: unsupported format string passed to numpy.ndarray.format
Pass on to numpy.ndarray .__ format__ Unsupported format string for

solve

a_ = np.array([12]).reshape(-1, 1)
a = model.predict(a_)
print("Predicting a 12-inch pizza.{:.2f}".format(a[0][0]))

TensorFlow issue: Expected int32, got list containing Tensors of type ‘_Message’ instead.

1. Foreword

Looking up a lot of information, I found that the originator of this error report was tf.concat “Expected int32, got a list containing tendors of type”_ The reason and solution of “message ‘instead.”

2. Reasons

The specific analysis of errors caused by TensorFlow version is as follows:

In TensorFlow versions before 1.0, the parameter order of concat() is number first and tensors second. The example is as follows:

tf.concat(3,pooled_outputs_i)

For versions after TensorFlow 1.0, the parameter order of concat() is tensors first and numbers second. For example:

tf.concat(pooled_outputs_i,3)

3. Solutions

Smart as you, you should know how to debug when you see the two explanations in the reason. That is to say, adjust the order of concat parameters and everything will be OK

Call to undefined method Illuminate\Foundation\Application::bindShared()

According to the previous method, the composer creates a package called illuminate/HTML. It is found that it cannot be used during use, and an error will be thrown when the composer updates

[Symfony\Component\Debug\Exception\FatalErrorException]

Call to undefined method Illuminate\Foundation\Application::bindShared()

reason:

I found out online that it is not supported after 5.1, so I removed illuminate/html from config/app.php

In providers

'Illuminate\Html\HtmlServiceProvider'

In aliases

'Form'      => 'Illuminate\Html\FormFacade',

'HTML'      => 'Illuminate\Html\HtmlFacade

Reexecution

composer remove illuminate/html

composer update

After 5.1, it is replaced with the package of laravelcollective/HTML.

composer require laravelcollective/html

In/config/app.php Add the following sentence to the providers array of

Collective\Html\HtmlServiceProvider::class,

In/config/app.php Add the following two sentences to the aliases array of

'Form'=>Collective\Html\FormFacade::class,

'Html'=>Collective\Html\HtmlFacade::class,

An error occurs when trying to pipe a python program to CD- sys.excepthook is missing lost sys.stderr

The answer was found on stackoverflow at

NB: I have not attempted to reproduce the problem described below under Windows, or with versions of Python other than 2.7.3.
The most reliable way to elicit the problem in question is to pipe the output of the following test script through : (under bash):

try:
    for n in range(20):
        print n
except:
    pass

I.e.:

% python testscript.py | :
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

My question is:

How can I modify the test script above to avoid the error message when the script is run as shown (under Unix/bash)?

(As the test script shows, the error cannot be trapped with a try-except.)
The example above is, admittedly, highly artificial, but I’m running into the same problem sometimes when the output of a script of mine is piped through some 3rd party software.
The error message is certainly harmless, but it is disconcerting to end-users, so I would like to silence it.
EDIT: The following script, which differs from the original one above only in that it redefines sys.excepthook, behaves exactly like the one given above.

import sys
STDERR = sys.stderr
def excepthook(*args):
    print >> STDERR, 'caught'
    print >> STDERR, args

sys.excepthook = excepthook

try:
    for n in range(20):
        print n
except:
    pass


 

How can I modify the test script above to avoid the error message when the script is run as shown (under Unix/bash)?

You will need to prevent the script from writing anything to standard output. That means removing any print statements and any use of sys.stdout.write, as well as any code that calls those.
The reason this is happening is that you’re piping a nonzero amount of output from your Python script to something which never reads from standard input. This is not unique to the : command; you can get the same result by piping to any command which doesn’t read standard input, such as

python testscript.py | cd .

Or for a simpler example, consider a script printer.py containing nothing more than

print 'abcde'

Then

python printer.py | python printer.py

will produce the same error.

When you pipe the output of one program into another, the output produced by the writing program gets backed up in a buffer, and waits for the reading program to request that data from the buffer. As long as the buffer is nonempty, any attempt to close the writing file object is supposed to fail with an error. This is the root cause of the messages you’re seeing.

The specific code that triggers the error is in the C language implementation of Python, which explains why you can’t catch it with a try/except block: it runs after the contents of your script has finished processing. Basically, while Python is shutting itself down, it attempts to close stdout, but that fails because there is still buffered output waiting to be read. So Python tries to report this error as it would normally, but  sys.excepthook  has already been removed as part of the finalization procedure, so that fails. Python then tries to print a message to  sys.stderr , but that has already been deallocated so again, it fails. The reason you see the messages on the screen is that the Python code does contain a contingency fprintf to write out some output to the file pointer directly, even if Python’s output object doesn’t exist.

I can provide details of the relevant parts of the C code if you’re interested.

 

Deeply impressed, very deep and in place.

I learned a few points, which are displayed as follows:

1. Pipeline command | flows data from standard output stdout to standard input stdin, so the command that does not read data from stdin cannot obtain data through pipeline command. Is it accurate

2. CD command is input through the command line of the terminal (device [keyboard] Read data, so Python <pythonScript.py>The CD will fail.

3. How to transfer values to commands such as CD?

It is quoted from Chapter 11 of Uncle Niao’s Linux private dishes: “in a string of commands, you need to provide information through other commands. You can use reverse single quotation marks”‘command ‘”or” $(command) ”

 

 

Git fatal: No configured push destination. Either specify the URL from the command-line or co

Git downloads its own project to local:

If you go out to work, you need to pull one of your git remote projects to the local computer;

 git init
 
 git pull https://github.com/TTyb/54qjLogin   (remote repository url)

After the downloaded item is changed, it will be pushed:

$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
 
    git remote add <name> <url>
 
and then push using the remote name
 
    git push <name>

At this point: git remote usage

This time the first push requires the URL.
 
$ git add --all
$ git commit -m "commit message"
$ git remote add origin 'remote repository url'
$ git push -u origin Corresponds to the remote branch name
 
 
 
Then the next time you don't have to go through all that trouble, just.
 
$ git add --all
$ git commit -m "info"
$ git push

ImportError: No module named google.protobuf.internal

>>> import caffe
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/home/ubuntu/caffe/python/caffe/__init__.py”, line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File “/home/ubuntu/caffe/python/caffe/pycaffe.py”, line 15, in <module>
import caffe.io
File “/home/ubuntu/caffe/python/caffe/io.py”, line 8, in <module>
from caffe.proto import caffe_pb2
File “/home/ubuntu/caffe/python/caffe/proto/caffe_pb2.py”, line 6, in <module>
from google.protobuf.internal import enum_type_wrapper
ImportError: No module named google.protobuf.internal

Solution
sudo apt-get install python-protobuf